top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Git: cherry-pick generates bogus conflicts on removed files

+1 vote
387 views

I have a commit I am trying to cherry pick that removes a number of files. It seems to generate conflicts for those files that have been modified on this branch since the common ancestor. Since they are being removed, I don't care about what changes have been made on this branch, just remove them. Even git cherry-pick -Xtheirs does not help. How can I avoid these conflicts, or accept the deletions? I tried git add -u, but that seems to take my version rather than accept the deletion, and there is no -u switch to git rm.

posted Oct 17, 2013 by Abhay Kulkarni

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Correct.

Without inspecting them, you would not know what you would be losing by blindly resolving to removal, hence we do not auto-resolve "one side removed, the other side changed" to a removal.

That does not need to mean that we should not make it easier for the user to say "resolve these 'one side removed, the other side changed' paths to removal".

"add -u" will be a way to say "Record the changes I made to my working tree files to the index". So presumably

 rm -f those files that the other branch removed
 git add -u

would be one way to do so. Of course, you can also use "git rm" directly, i.e. git rm -f those files that the other branch removed

answer Oct 17, 2013 by Garima Jain
Similar Questions
+2 votes

In coreboot we try to check for whitespace errors before committing. Of course a pre-commit hook is the way to go, but unfortunately it is not so simple (at least for me) as the following requirements exist.

  1. Only the files actually committed should be checked. That means running git commit -a, abort that and then running git commit some/file should only check some/file for whitespace errors.

  2. There are certain files that are allowed to have whitespace errors. In our case these are *.patch and *.diff files which by design seem to contain whitespace error.

Currently the whole tree is checked, which takes a lot of time. I tried to come up with a patch, but failed so far. Best would be to have

$ git diff --check --only-committed-files --exclude "*patch$"

where I could not find a way for the last to switches.

Currently, I would use

$ git diff-index --cached --name-only $against -- | grep -v patch$

and pass that list to some whitespace check program. Unfortunately that still does not fulfill the first requirement. What am I missing to solve this elegantly?

+1 vote

I have a question about merge commits. Now when I perform git pull from somebody. Sometimes I'm getting a merge commit where I should write a merge commit message. Sometimes it does not happen, I just hit the git pull and it pulls the updates without creating a merge commit.

What is the difference? note that the files modified in the new commit -when getting a merge commit- are only maintained by a single user. And how can I avoid these merge commits as long as the file is maintained by one user ?

0 votes

There are shorthands for going back from HEAD, but not for the initial commit, AFAICT.

I often want to do this when rebasing, and have come to tagging the initial commit in my repos with INITIAL.

Is there a better syntax I'm missing?

+1 vote

I have two branch in one repository that I need to maintain for 2 different deliveries.
Say branch1 and branch2 in test.git repo.

test.git
- branch1
foo_v1/text.txt
foo_v2/text.txt
- branch2
foo/text.txt

branch1 is developers branch all source looks version'ed manner and branch2 is superset for branch1, example foo_v1 and foo_v2 are the directories in branch1 where developer will update the latest one here foo_v2 and branch2 foo is same as the latest one of branch1 for an instance.

Suppose developer send 10 patches on branch1 where are changes in terms of _/ then I need to apply on my local repo branch1, till now is fine then I need to apply same 10 patches on to my branch2 where source tree which is quite question here how can I do.

+2 votes

Can someone help me on how to delete an intermediate commit?

...