I want to push several single commits to our main git repository. After doing some reading though it sounds like I have to reorder the commits in order to do this, because git will only push all commits up to a specified commit. First, I don't really understand why this isn't just built in to git (I'm a git newbie). Regardless, I need to reorder the commits and I'm using TortoiseGit. I've found how to get to the rebase menu, but I don't know which options to choose. To get to the rebase menu I:
- Right clicked on the directory and chose TortoiseGit / Show Log
- Browsed to and selected the commit I wanted to reorder.
- Chose "Rebase "master" onto this".
I'm presented with a dialog but I don't know what any of the fields mean.
First, there is the branch field, I see master and a few remotes options. I don't have any branches. I cloned a repository and have been working soley from the local clone so far, why is there a branch option?
Second, there is a little button with left and right arrows on top of each other. What is this button for?
Third, there is an upstream field, by default it has the repository's SHA selected. When I click on the field I see FETCH_HEAD, master, and a few remotes options.
I expect to see a list of commits and I can just move my commit up and down. I am able to see a list of commits by checking the Force Rebase option. Is this what I need to do? What am I forcing though, I thought I just wanted to do a plain old rebase?
Again, I'm a git newbie, any help is appreciated.
You are on the right track. Force Rebase is the option you need to use. After you see the commits using the Force Rebase option, select a commit and use the Up/Down buttons to re-order your commits. Press the Start rebase button after you have ordered them as desired.
As regard to why you need to select Force Rebase; Rebase is usually done when you want base your current branch off a newer commit. Since your current branch is already based on the commit that you selected, there is nothing to rebase. In your case, you are simply trying to reorder your commits instead of rebasing. There is nothing wrong in using rebase for that. Just need to select Force Rebase explicitly.
Here's the full steps from following geoji's answer.
This is a workaround solution. Here's what I found:
Definition of upstream and downstream: Definition of "downstream" and "upstream"
Definition of FETCH_HEAD: Search for "what is FETCH_HEAD in git" in Google.
Can I use git command line tools with TortoiseGit?: Can I use command-line Git tools and TortoiseGit simultaneously?
How to reorder commits with git: http://blog.dennisrobinson.name/reorder-commits-with-git/
In this blog post he suggests to use:
I used
instead. This will provide you with a list of commits from the head to SHA_of_oldest_commit. To reorder the commits I just reordered the lines like I wanted them and saved and closed the file.
I was not able to reorder the commits in TortoiseGit even with the help of answers above. Finally I end up with installing Source Tree with much better UI where you can reorder history with just one click (Rebase children of Hash interactivelly...) by Down and Up buttons.