Difference between revisions of "Git branching and merging"
(Created page with "=Git branching and merging= Creating, merging and deleting branches with git is very easy. ==Creating a new branch== To create a new branch of development we can use: <pr...") |
m |
||
Line 1: | Line 1: | ||
<yambe:breadcrumb>Git</yambe:breadcrumb> | |||
=Git branching and merging= | =Git branching and merging= | ||
Line 53: | Line 54: | ||
git branch -d <branch_name> | git branch -d <branch_name> | ||
</pre> | </pre> | ||
<yambe:breadcrumb>Git</yambe:breadcrumb> |
Revision as of 05:07, 28 June 2013
<yambe:breadcrumb>Git</yambe:breadcrumb>
Git branching and merging
Creating, merging and deleting branches with git is very easy.
Creating a new branch
To create a new branch of development we can use:
git branch <branch_name>
Listing existing branches
To list all existing branches we can use:
git branch
Checking out given branch
At any time we can chose to work on given branch by checking it out using:
git checkout <branch_name>
Merging current branch with some other branch
To merge current branch with some other branch we can use:
git merge <other_branch_name>
after checking out current branch.
If merge is successful then commit is done with new merge automatically. However if there are conflict then CONFLICT error messages are shown. To see the conflicting lines after merge we can use
git diff
command which lists conflicting lines. In such cases 'git status' shows files with conflict as 'unmerged paths'.
In case of conflicts we should edit the conflicting files to remove the conflicts. Then we should use 'git add <modified_file>' to add the new modified file to index. Then finally 'git commit' to commit resolved file to repository.
Deleting a branch
We can delete a branch (probably after it has been merged with master) using
git branch -d <branch_name>
<yambe:breadcrumb>Git</yambe:breadcrumb>