How to merge your changes from one branch to another in GIT

How to merge your changes from one branch to another in GIT:

1. With this post we will see how to merge your changes to production branch or another branch. Also you will get some idea about merge command & when you want to this command aswel.

2. Whenever you want to start new task than the best way to start new branch instead work directly from production branch.

In that new branch you add & modify any changes. Once your task is completly done then merge those changes changes to production branch. Until complete don’t merge changes to production.

Example: Now am standing in first_branch, here i created new file and also i modified one existing file & i added & commit my changes to first_branch.Now my task is ready to move master branch (here am maintaining master as my production branch)

3. Use following command to merge your changes, first you have to switch to production branch (or switch to branch where you want to merge your changes)

git checkout master

git pull origin master (Syntax: git merge <BRANCH NAME WHERE YOU WANT TO MERGE UR CHANGE>)

git merge first_branch (Syntax: git merge <BRANCH NAME WHICH YOU WANT TO MERGE>)

Updating 50437f0..7d0c66c

Fast-forward demofile_first.html | 5 +++++ first.html          | 1 + 2 files changed,

6 insertions(+) create mode 100644 demofile_first.html

Here first.html file is exist file and i added some additional changes, demofile_first.html file is my new file which i created from first_branch.

After merge the branch those changes will available/merged from master branch code(production)
4. Till now your changes is merge with you local master branch, we should move those changes to remote repository,

git push origin master

git pull origin master (from your remote repository)

Note: If you want to search any keyword in git use git grep “YOUR KEYWORD”

 

“Stop Smoking. It’s Injurious to Health

 

Leave a Reply