I want a branch to hold all the files from my master branch except for foo.txt and foo2.txt. How do I do this?
Asked
Active
Viewed 8,713 times
1 Answers
14
You have to branch off from master. Check out a new branch and remove the files you do not want.
git checkout master
Once in master:
git checkout -b new_branch
rm foo.txt
rm foo2.txt
git add -u
git commit -m "removed foo and foo2"
git push origin new_branch

Joel
- 4,503
- 1
- 27
- 41
-
2Note that this *probably* won't work as written. You need the `-u` option provided to `git add` if you want it to stage the deletions. (http://stackoverflow.com/q/2190409) – Craig Otis Feb 04 '15 at 21:40
-
Why do you need the -u? – user678392 Feb 04 '15 at 22:24
-
1git add -u will operate on the entire tree it will commit the deleted files – Joel Feb 04 '15 at 22:25