Sunday 26 March 2017

Git Commands Part 2 - Simple Commit, Pull and Push - Master/Branches

     With continuation to the post


6.     Commit the Changes to the local repository -m indicates the message content on the “message” which is used for the future references & Push the same to the remote branch

git commit -m "employee model class and method added"
git push origin branch0 

7.     Every time we need to keep our branch Ahead of master not behind, because it might have conflicts with other branch code, so we need to resolve and keep it has updated one. (This conflicts and resolve feature will be explained in the next post)

If the remote branch seems to be behind, we need to update the local
repository equivalent to that code.

Go to your local repository first we see how to take an update to the master.

git checkout master
git pull

The master branch will be updated.

Checkout the other branch, get the updated code if anything is need to be get it from the remote branch.

git checkout branch0
git pull
git push origin branch0

Get the updated code from the remote master and push the code to remote branch

git checkout branch0
git pull origin master
git push origin branch0

Same the we can get the updated code from another branch as well

git checkout branch0
git pull origin branch1
git push origin branch0

No comments: