Merging all the commits from one branch
to another branch.
For example, currently I am working
with 5.5 branch for new features and wanted to pull the changes from
5.0 for fixes which are made.
Currently my branch is pointing to
Dev-5.5
$ git merge Dev-5.0
If you have all the 5.0 changes in
local system, above command will work fine.
If your local Dev-5.0
branch is not up-to-date, first pull the changes from central
repository.
$ git checkout Dev-5.0
Now you are in Dev-5.0 branch.
$ git pull origin Dev-5.0
This will fetch all the latest commits
from origin/Dev-5.0 to local Dev-5.0 branch.
Now, go back to Dev-5.5 branch, to
where you want to merge.
$ git checkout Dev-5.5
Now, you are in Dev-5.5 branch.
$ git merge Dev-5.0
This merges Dev-5.0 commits to Dev-5.5
branch, if none of the files having conflicts.
If any file is having conflict, merging
will be failed and shows the conflicted files in the console.
Go to the specific files and resolve
the conflicts.
Once conflict is resolved, add that
file and commit them.
$ Git add hello.java // this is my
conflicted file.
$ git status // this will show all the
files still need to be merged and including with conflict resolved
file.
$ git commit // remaining things are as usual.
No comments:
Post a Comment