I searched internet and SO but could not get solution to this issue.
I am using git. I have the code, which has a branch B1 on computer C1. On another computer C2, I cloned this branch and locally, made one more branch B2. B2 is not pushed to central repository.
B1 and B2 are quite same, except one file FILE1. So I added that file to .gitignore and committed in B2. Now whenever I do some coding in B1, I push it in central repository. To get these changes on computer C2, I do
git pull origin B1
while I am on branch B2. But this gives error message:
CONFLICT (content): Merge conflict in FILE1
I wanted to ask, if there is a better way of bringing changes made in B1 to B2 (without bringing FILE1) or how can I improve my current method. Thanks for help, as I am new to git.
I think you’re misunderstanding the purpose of
.gitignore:So if your file is already being tracked by Git (which it seems to be in your case), adding it to
.gitignorechanges nothing.When you get a merge conflict, it means that the file has changed both on your current working tree and where you’re merging from (in your case, the remote repository). You **must* resolve any and all merge conflicts. There are lots of resources for how to resolve merge conflicts, the Git User Manual among them. You can also specify that Git use the local or remote copy to resolve conflicts:
If you never meant to track the file, you can untrack it:
As Greg mentions, if your intent is for the file to be a template configuration, name it as such, and then copy it and add the specialized version to
.gitignore.