Question

Please point me if there is a duplicate to this question in stack overflow.

I would like to know if there is any way to push selected versions( or the most recent commit version) to the remote repository? When I push It pushes all the un pushed versions- am I missing something?

Was it helpful?

Solution

A Git commit depends on all of its parent commits, so pushing the last commit but not the second to last one is impossible.

The other way around is fine though, i.e. you don't have to push the tip of a branch. For example, if you want to push the second to last commit on the master branch (leaving the very last one un-pushed) you can use master~:master as your push refspec. The gitrevisions(7) man page describes the different ways to express commits.

As pointed out in another answer, you don't have to push all branches either. The current version of Git pushes all branches with matching names if you don't specify which branch to push, but I believe this will change in Git 2.0.

OTHER TIPS

Using:

git push origin HEAD

Will push just your current branch.

git push origin foo:bar

Will push the local branch named "foo" to the "origin" remote, and name the branch on the origin server "bar".

There is lots of documentation on Git:

http://gitref.org/remotes/#push https://www.kernel.org/pub/software/scm/git/docs/git-push.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top