Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Thursday, September 18, 2014

How to resolve merge conflicts after git rebase ?

Have you faced a merge conflict while performing git rebase operation ? This is quite possible  if two commits modify the same line in the same file. Now git is confused which change to apply.
Git gives us several options in such a case :
  • git rebase --continue
  • git rebase --abort
  • git rebase --skip
1. git rebase --continue
Used in case if you have manually corrected the conflicted files. So after resolving the merge issues manually , use command rebase --continue so that git can continue processing the rest of the rebase.

2. git rebase --abort
Use this command if you want to completely undo the rebase. So the branch will return to the state that was before rebase was called.

3. git rebase --skip
Used to completely skip the commit. None of the changes introduced by the commit will be included.

Happy Learning !!!


Thursday, May 1, 2014

How to amend the last commit in Git ?


Have you ever faced a situation where you left something out of your last commit ? It may be a file or an extra change to a file you just committed. 

Such kind of scenarios can easily be handled with Git amend command .

How does it work ?
1. Just add the file using git add ( Like what we do for         normal commit ).
    git add <file>

2. Now commit the changes with -amend argument.
    git commit --amend

    If you don't specify a commit message with -m , git picks the previous commit message as    a default.

How to see the amended commit ?
We can use git log --stat to see the amended commit with extra change .

You can also see this page for more information on git commit.