3

Suppose I have made five commit in git say 1 -> 2 -> 3 -> 4 -> 5 in order.

I know it is possible to push selected commits lets say commits 1 and 2 using git bash which is explained here Push selective commits using git bash

But, I want to know if this is possible using Atlassian SourceTree? It would be really convenient feature to have.

Another question: How to push only commits 2 and 4 using git bash without affecting other commits? I know this can be done by reordering the commits? But, I want to know if this can be done without any reordering.

Community
  • 1
  • 1
  • As of 2013, this functionality was not there for git https://answers.atlassian.com/questions/217192/push-only-some-commits – jaredready Oct 23 '15 at 16:18
  • `git` does not push arbitrary commits. You have to push a reference, i.e. either a branch or a tag, and that makes sure that the entire graph up to that reference is present and fully connected in the remote. A repository isn't just storage for random commits that have no connection to other commits. – twalberg Oct 23 '15 at 18:56

2 Answers2

1

First of all, like ResidentBiscuit suggested, SourceTree does not support this functionality but a Jira ticket has been created for this. You can track this ticket to figure out when will this be added in SourceTree.

In the meanwhile, there is a good feature in SourceTree that can come handy to solve this issue along with git bash. First, you need to reorder the commits. Click on Repository -> Interactive Rebase. It will give you a list of commits and you can reorder commits so that 2 and 4 comes before 1, 3, 5. Then, you can issue following command in git bash

$ git push origin master~3:master

This command will set head to three commits ago and push it to the remote master branch so that only 2 and 4 will be pushed to the remote master.

user109260
  • 878
  • 7
  • 22
0

Looks like it's not supported in Source Tree See this post

sinjar
  • 115
  • 2
  • 6