0

I have a SourceTree issue with moving between branches due to file conflicts. Basically I am working in a small team and we each have our own Web.config files which have distinct properties to our individual machines (like directory paths eg. C:/Mark/Documents/Project/) Each time I move between branches I have conflicts because of these files. I do not want to commit these files because it means when someone else moves to that branch they will need to commit their Web.config changes - which means when I return to it I will need to commit the files again, and so on. Is there some Git tool or procedure I can use to get around this issue we are having.

Thanks in advance

Mark
  • 501
  • 2
  • 11
  • 28

2 Answers2

1

If I understand you correctly all you need to do is add Web.config to your .gitignore.

That will prevent git from tracking changes to the file. Each user can do whatever they like to it without creating conflicts.

dlsso
  • 7,209
  • 1
  • 21
  • 31
  • We thought about this but we also believe it is a dangerous operation as we may miss Web.config changes in the future which can be critical – Mark Jun 24 '16 at 01:21
  • Then it's kind of a case of having your cake and eating it too. You can't both track and not track the file. If you don't make meaningful changes to the file very often I would `.gitignore` and then force add when needed. – dlsso Jun 24 '16 at 01:28
  • Note: **no user should be checking in code that is specific to their build.** If that is the case, nip it in the bud. And as long as you don't have *that* problem you should just be able to take "mine" in source tree without issue. – dlsso Jun 24 '16 at 01:30
  • 1
    You can move out the portions of the Web.config that are machine specific into another referenced config file that you .gitignore and check in Web.config with the project specific essential config – Seafish Jun 24 '16 at 02:21
  • @Seafish Cool, I didn't know you could split it out. That's probably his best bet then. – dlsso Jun 24 '16 at 15:50
  • Thanks @Seafish i'll look into that as an fix. Appreciate the help guys – Mark Jun 26 '16 at 23:52
0

I guess that file is modified by someone or by something, but not committed before you switch to another branch. Make the work tree clean before switching. Discard the changes of that file if they are not needed via git checkout -- <path_of_that_file>. Commit them if they are needed. Run git status to see if the work tree is clean.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53