kaberett: Trans symbol with Swiss Army knife tools at other positions around the central circle. (Default)
kaberett ([personal profile] kaberett) wrote in [site community profile] dw_dev_training2013-05-14 07:43 pm
Entry tags:

My Exciting Week With Git

I have just pushed what is hopefully the final version of my patch for Bug 5030.

As you can see from comments on that git page, it took quite a lot of editing for me to get it to the final point. This means I ended up running git commit several times (here's the handy wiki doc).

For tidiness' sake, [personal profile] fu wanted all of the commits in that branch merged into a single commit using git rebase.

So, because I ended up doing this several times (and forgetting in between times how I'd done it), here is Wot I Did:
0. Swore a lot and asked for help.

1. git branch
... to check I'm in the branch I want to be.

2. git rebase -i HEAD~[X]
"-i" means "interactive".
"[X]" needs replacing with the number of commits you had as part of this bug fix. For this bug, I'd got my first commit, in which I'd done most of the work; and my second commit, in which I'd corrected bits and bobs I'd got wrong in the first one, so I replaced "[X]" (in its entirety, including the brackets) with "2".
The interactive rebasing screen is brought up, with a list of the last two commits I made, their ID numbers (not sure what git calls them and I probably should be), and their brief commit messages.
Each line is by default started with "pick". For the first commit I replaced "pick" with "reword" (to allow me to update the commit message); for all subsequent commits I replaced "pick" with "fixup".

3. git push --force origin [branchname]
Because you've merged everything into one commit, if you try to push without setting --force you'll get the error "Updates were rejected because the tip of your current branch is behind its remote counterpart" as you've merged

That is a thing that I did! And explained really badly. But at least now there is outline for asking further questions/putting it in the wiki?

[personal profile] jewelfox 2013-05-16 09:41 am (UTC)(link)
Oh my goddess, git is so aptly named. >_>;; I interned for GNOME, and my mentor had to spend several hours during one hackfest just disentangling the hairball that my local archive had become.

Congrats for surviving!