-
Notifications
You must be signed in to change notification settings - Fork 1
Git Branching
Kenneth Kasajian edited this page Mar 26, 2021
·
28 revisions
git branch experimental
Creating branches just creates a new tag pointing to the currently checked out commit.
git branch
git checkout experimental
git checkout -b branchname
git checkout master
git merge experimental
If there's conflicts, markers will be left in the files. type git diff
to see.
git merge
will create a new commit with two parents. The resulting commit snapshot will have the all of the work that has been done in both branches.
If there was no divergence between the two commits, git will do a "fast-forward" method merge.
git branch -d experimental
will only delete it if the changes are in the current branch.
git branch -D crazy-idea-branch
-D
delete a branch irrespective of its merged status.
git branch -m <old_name> <new_name>
git push origin origin/<old_name>:refs/heads/<new_name> :<old_name>
See Git---Push
Publish:
git push -u origin <branch_to_publish>
Unpublish
git push origin :<branch_to_publish>
or
git push origin --delete <branch_to_publish>
git branch bug111
git checkout bug111
git commit
git checkout master
git merge bug111
git branch bug111
git checkout bug111
git commit
git rebase master
To move master to the end (i.e. bug111), use one of the following:
git checkout master
git reset bug111
or
git branch -f master bug111
Hand-pick each line of the files to be merged, bypass Git from getting involved in the merge process:
git checkout master
git difftool local-branch HEAD
git merge-base release master
or
git merge-base master head
git log head --not master
git branch --contains <commit>
or
git reflow show --all | grep <commit>
git logs --first-parent master