Is it possible to have repo specific .gitignore files? Eg:
[origin] .gitignore:
[another] .gitignore:
My Situation:
Having a file named
alex.todo
which contains my personal notes about the project. I have two remote repo to push(origin
andalex
). One for sharing the code with other developers(I use.gitignore
to exclude thealex.todo
file), one just for backing up this project which is ok to preserve thealex.todo
file.
My final solution:
Using a temp branch to push the
alex.todo
to the backup repo.
# Step 1
git checkout -b alex # 'alex' or whatever branch name you prefer
# Step 2
# now you can edit your .gitignore to include your 'alex.todo' file
# Step 3
git add . && git commit -m 'commit some ignore files'
git push alex alex:master # git push :
# Step 4
git checkout master # return to branch master and do any editings(commits)
# Step 5
# make sure branch alex is in sync with master whenever you want to push the project to the backup repo
git checkout alex
git merge master # .gitignore will not automatically be included for commit unless specifically added
# now you can repeat step 3 to push the project to the backup repo