Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push single file to a remote tracking branch

Tags:

git

github

Folks,

This is my use case: I have 3 branches, all three are remote tracking branches.

git branch
  release-alpha
* release-allUS
  master

Now I added a new file in release-allUS branch, I made a commit by doing this:

 git add filter_driver.rb 
 git commit -m "driver code"

Now I want to push only this file to the remote release-allUS branch, How do I do that? Thanks a lot for any feedback.

like image 404
Rubyalto Avatar asked Jun 17 '11 17:06

Rubyalto


Video Answer


1 Answers

Since all that you committed locally was that one file, a git push to your remote will work. Push will only push what has been committed locally.

git push origin release-allUS

As manojlds pointed out in the comments, this will only work if nothing else has been stages and there are no other unpushed local commits. If that is the case, you are are probably best creating a new tracking branch from the remote, cherry picking the local commit into the new branch, pushing to the remote, then rebasing the original tracking branch.

like image 60
vcsjones Avatar answered Sep 22 '22 21:09

vcsjones