user678392
user678392

Reputation: 2031

How do you remove files from one and only one branch in git

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?

Upvotes: 6

Views: 9506

Answers (1)

Joel
Joel

Reputation: 4593

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

Upvotes: 14

Related Questions