Reputation: 2123
I have multiple unsynced, outgoing commits on my branch. I want to push one of them to my online repo, while I want to wait with pushing others (they're part of a larger process).
If you look at the screenshot below, how can I push only the first commit?
Upvotes: 3
Views: 3861
Reputation: 6172
There is no simple way of doing that. I don't know how to do this from Visual Studio, but here is below the way how this can be done from command line using git utility.
Let's assume that your main branch has name "master" and you are currently checked in to it.
Create a temp branch from your master:
git checkout master
git branch temp
Reset master branch to origin/master so that to return it to the initial state when it didn't have your commits yet:
git reset --hard origin/master
Get all commits from remote master to synchronize your local and remote "master" branches. This step is necessary if there are commits you don't have yet in your local copy e.g. smbd else pushed while you were working locally. Anyway it worth to do it just to make sure:
git pull origin master
Now you can cherry-pick your last commit to master:
git cherry-pick <hash_of_last_commit_in_temp_branch>
Now you can push this commit to remote:
git push origin master
Now merge the rest of your commits from temp branch back to master branch:
git merge temp
And finally remove temp branch:
get branch -d temp
That's it.
Upvotes: 2
Reputation: 8343
There is no simple way and Visual Studio 2013 Git integration offers no help; I would use Git command line or similar.
You should create a new branch to park all the commits, switch to the current branch (is it master
?), reset it to match TFS status (i.e. origin
) and cherry-pick the commits you want to apply and push.
Upvotes: 1