Search code examples
gitgit-gui

Is there any way to push only selected versions to a remote repository?


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?


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.