-
Create Branch -
git branch <BranchName>
-
Push branch for the first time
git push -u origin <BranchName>
-
Push branch to another repo
git push <Url/Remote> [+]<LocalBranchName>:<RemoteBranchName>
the optional
+
sign is in order to force the push even if it is not fast-forward
-
Merge Branches -
In order to merge branch
Remote
into branchLocal
, we perform the following commandgit checkout <LocalBranchName> git merge <RemoteBranchName>
-
Merge Options -
-
--no-commit
This means that the merge will be performed and the results indexed but not committed. This allows one to inspect and test the merge before committing
-
--squash
This means that the merge will be performed but all changes in the
Remote
Branch will be squashed together into a single commit and will not mix up the histories of theLocal
andRemote
branch. However, this also means that the new merge commit will not contain as a parent, the commit ofRemote
branch that it merged with.
-