There's a repository that's not mine on github. I cloned it so now I have a copy of it in my github account and I have a copy of that repo on my computer. I made a branch that has its own directory and a whole lot of files which I then committed to that branch, call it apple. When I switch back to the master branch I notice in status that the directory and all the files in it that I committed to on apple show up in the status. So now I have a hundred or so files that every time I switch over to master are visible.
My question is how can I make it so that when I switch back over to master those files I have in the apple branch are ignored? I'm sure I could amend the .gitignore in master but that would be changing the project's .gitignore.
Thanks
EDIT: Commenters have pointed out that if the files were committed in another branch they should not show up when I switch branches and this is correct. After working with everyone who helped me here what I discovered had happened was one of the subdirectories in the directory I created on the apple branch had its own .gitignore that ignored a lot files. That .gitignore was committed in the apple branch and when I switched branches (for example to the master branch) that directory specific .gitignore disappeared and all the files that were originally ignored on the apple branch showed up in any other branch in git-gui as being untracked. So I had a whole lot of files that I thought were committed on the apple branch but actually weren't. Sorry for the confusion! I will be marking Ryan Stewart's answer as correct.
You can set your own 'global ignore' file as such:
git config --global core.excludesfile ~/.gitignore_global
You then populate ~/.gitignore_global
as you please. Additionally you can edit
.git/info/exclude
just like .gitignore
but it will only apply to that .git repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With