0
  1. In .gitignore I added *.o.
  2. I switched to my second branch (using console)
  3. I created test.o with touch test.o
  4. I used git pull
  5. When I use git status I can see, that test.o is untracked, and can be tracked.

I expected that git will totally ignore test.o and dont metion about tracking. I cant use git add . now, because it will track test.o.

Is there a possibility to tell git to totally ignore test.o file?

David Konn
  • 29
  • 4
  • see here https://stackoverflow.com/a/11451731/294949 – danh Jan 16 '18 at 18:14
  • You had to commit the changes to gitignore file after step 1. Was that commit merged to the branch you switched to? Otherwise, within that other branch, it is not going to ignore that pattern. – GermanC Jan 16 '18 at 18:14

1 Answers1

0

I switched to my second branch

Does the branch have *.o in its .gitignore? If no — *.o files are tracked in the branch.

Have you committed the change in .gitignore? Merge or cherry-pick the commit into the second branch to propagate the change to the second branch. Or just edit and commit .gitignore again.

phd
  • 82,685
  • 13
  • 120
  • 165
  • Do I have to create `.gitignore` per each branch? I Thought that `.gitignore` in `master` branch is for every branches. – David Konn Jan 17 '18 at 09:49
  • No, it's per branch. You may have global `~/.gitignore` and you have per-repository `.git/info/exclude` files but their disadvantage is they are not shared with commits/pushes. – phd Jan 17 '18 at 10:07
  • So when I created `pc` branch and merged with `master` I have no `.gitignore` in `pc` branch? – David Konn Jan 17 '18 at 10:10
  • Should have — it must be a part of merge. – phd Jan 17 '18 at 10:11
  • No. I dont have. This is the proof: https://puu.sh/z3szT/9609df2f62.gif. First tab is `master`, and second `pc`. – David Konn Jan 17 '18 at 10:13
  • After you've merged `master` into `pc` you should have `.gitignore` in `pc` branch. Unless you resolved conflicts by removing the file. I don't understand your video, there are too many windows and mouse movements, and I'm text-mode guy, command line user. – phd Jan 17 '18 at 11:29
  • Well as you can notice, there are not conflicts and there is no `.gitignore` in `pc` after `merge`. – David Konn Jan 17 '18 at 11:52