Monday, January 5, 2015

GIT - A Simple Reference -- continued 1

To rebase the local dev branch, 
$ git rebase -p dev

If git conflicts occur, to list the conflict files do this,
$ git status

The conflict file looks like this,

<<<<<<< HEAD
<Code Modified>
=======
<Old Code>
>>>>>>> branch Name

When the conflict occurs, git internally creates a temporary branch (no branch),
To confirm that do,
$ git branch
* (no-Branch)
* dev
* feature/xyz
* master

Manually merge the changes and do the following,

$ git add <file-name>
$ git commit -m "Meaningful Comment" <File Name>

$ git rebase --continue

On completion the temporary branch(no-branch) is deleted and control comes to your feature branch,
$ git branch
  dev
* feature/xyz
  master
 
Then finish the feature and push to origin/remote branch,

$ git flow feature finish <ID>
$ git push origin dev

If the origin dev has been updated in meanwhile, then the git push origin dev will fail with following message,

To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.


Then to resolve this do the following,

$ git fetch
$ git rebase -p origin/dev
$ git push origin dev

No comments:

Post a Comment