- Show list of branchs
git branch -a
- Create branch
git branch new-branch
- Switch to new-branch
git checkout new-branch
- Delete branch (which is not merged)
git branch -D new-branch
- Delete branch after it is merged
git branch -d new-branch
- First go to the branch, that we want to merge into (master)
- merge
my=branch
intomaster
(current branch)
git merge my-branch
- created branch
cc
frommaster
- made changes in
master
- made changes in
cc
- unfortunately in both branchs, a same file has also been changed.
- so switch to
master
- merge
git merge cc
- It will say CONFLIT, and append the code of both branch in that file
- Go, edit that file
- then
git add .
git commit //only commit, no message
:wq //if it is vim
- congratualtions, branch
cc
is merged intomaster
successfully
- push
cc
to remote (only cc)
git push origin cc
- pull changes
git fetch
- pull
cc
to local (only cc)
git pull origin cc
- create pull-request on github site
- it can be merged to
master
on github site
- Create new branch and switch to it
git checkout -b my-new-branch
- A created new branch
aa
- A made changes and pushed it to remote
git push origin aa
- B pulled changes
git fetch
- B switched to
aa
branchs (yes, it is auto setup)
git checkout aa
- B makes changes to
aa
- B pushes it
git push origin aa
- and so on
Happy coding