Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On conflict, GitHub for Windows puts me in "rebasing" state, how to go from there?

I recently started using GitHub for Windows.

I just got a conflict. On command line I would know how to handle this, but GitHub for Windows choosed to put me in a state I am not familiar with:

C:\Users\w\Documents\GitHub\CmisSync [(6026d18...)|REBASE +0 ~1 -0 !1 | +0 ~0 -0 !1]> git status
# Not currently on any branch.
# You are currently rebasing.
#   (fix conflicts and then run "git rebase --continue")
#   (use "git rebase --skip" to skip this patch)
#   (use "git rebase --abort" to check out the original branch)
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
...

I fixed the conflict, committed the files, but when I run git push I am told:

fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD) state now, use

    git push origin HEAD:<name-of-remote-branch>

What is the recommended way to get my merging commits to the remote master?
I doubt git push origin HEAD:master will achieve this.

like image 470
Nicolas Raoul Avatar asked Mar 01 '13 03:03

Nicolas Raoul


People also ask

How do I get out of rebasing?

You can run git rebase --abort to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called. You can run git rebase --skip to completely skip the commit.

How do I stop rebase in progress?

If you prefer to skip this patch, run "git rebase --skip" instead. To check out the original branch and stop rebasing, run "git rebase --abort".

How do I complete git rebasing?

When you're finished making all your changes, you can run git rebase --continue . As before, Git is showing the commit message for you to edit. You can change the text ( "i cant' typ goods" ), save the file, and close the editor. Git will finish the rebase and return you to the terminal.


2 Answers

As we where saying with Simon Boudrias, if you don't really know what you've done during a rebase, the best thing to start off is with a git rebase --abort. As the verb says, it aborts the current rebase, and leaves you with your repository and working copy in the same state it was before the rebase started.

After that, you should do whatever you've done that started the rebase process (I don't think you said what it was, but don't think it's really important, either). Surely the rebase will start again, and here is where your original question begins to be answered.

As the status output says, you seem to have conflicts. You should resolve them (I usually use git status --short plus git mergetool to resolve them with meld), then git add the files. When status is OK (say, every file that would have to be commited is added, with no conflicts), you should git rebase --continue instead of git commit.

The idea is that git rebase applies a group of commits on top of a given commit. I don't really know what commits are being applied on top of what, but it's important to have that in mind. Keep in mind that there can show multiple conflicts, because commits apply one by one. Use git log to see what was the last commit applied, and I think there has to be a file in your .git/ directory with the commit message of the commit that's currently being applied.

It's a commmon newbie error (we've all been there :)) to try to include changes in the files during the conflict resolution without knowing (or forgetting) they were going to be applied by a latter commit.

So, hopefully, after resolving some conflicts, adding the files and git rebase --continueing them, you should arrive to a happy functional repository, and you'll be able to git push from there on.

Lastly, but not least important: after all the rebase stuff, use git log to check you're not modifying any public commit. Say, that your new branch contains the remote's HEAD commit. Rebasing is powerful and very dangerous. You don't want to rebase a public commit - it's maybe the only git pain you don't want to face :)

like image 80
mgarciaisaia Avatar answered Oct 11 '22 04:10

mgarciaisaia


You first need to end the rebase mode by calling git rebase --continue once you resolved your conflicts. This should then put you back on the branch you were pulling (in your case master). You'll notice this happens when the command line (posh-git plugin) will indicates master instead of REBASE

Then you could push using git push origin master. The extra parameters may be autofilled by Git, but that'll depends on your settings.

like image 45
Simon Boudrias Avatar answered Oct 11 '22 04:10

Simon Boudrias