Monday 30 October 2017

git branching and merging

git branching and merging


# My repository currently pointing to master branch

$git branch
* master
gatekeeper
development

# Create a new branch from master to work with the task.

$git checkout -b bug-111

It will creates a new branch and switched to bug-111

Work on the issue/task

Now commit your changes

$git commit -m "Bug-111 changes " file1 file2...

Now switch to any branch for which you want merge your code

$git checkout gatekeeper

# Now my repository points to gatekeeper branch
# Inorder to avoid conflicts, I will update the references and I will pull the code from remote git repository .

$git fetch
# this command update all the referrences

$git pull origin gatekeeper
# To get latest  changes and avoiding conflicts.

$git merge bug-111

# After merge if you get any conflicts, rectify those conflicts and commit the changes by using below command

$git commit -im "bug-111 conflicts resolved" file1 file2

$git push origin gatekeeper

# To merge our changes to remote repository.