Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tips:git [2018/02/06 15:51] – [or rebasing] scipio | tips:git [2019/03/13 09:30] (current) – [apache git] scipio | ||
---|---|---|---|
Line 74: | Line 74: | ||
+ | ===== create branch with current changes ===== | ||
+ | |||
+ | < | ||
+ | git checkout -b newBranch | ||
+ | </ | ||
+ | |||
+ | ===== tag ===== | ||
+ | |||
+ | < | ||
+ | git tag -a v1.1 -m " | ||
+ | git push origin v1.1 | ||
+ | </ | ||
===== new remote branch ===== | ===== new remote branch ===== | ||
Line 107: | Line 119: | ||
git branch -d [branch] | git branch -d [branch] | ||
</ | </ | ||
+ | |||
+ | ===== rename branch (local and remote) ===== | ||
+ | |||
+ | |||
+ | < | ||
+ | git branch -m new-name | ||
+ | |||
+ | # Delete the old-name remote branch and push the new-name local branch. | ||
+ | git push origin :old-name new-name | ||
+ | |||
+ | # Reset the upstream branch for the new-name local branch. | ||
+ | git push origin -u new-name | ||
+ | </ | ||
+ | ===== Preserve specific files while merging ===== | ||
+ | |||
+ | start by defining a merge driver that would always favor our current version of the file | ||
+ | < | ||
+ | git config --global merge.ours.driver true | ||
+ | </ | ||
+ | |||
+ | into repo mark examplefile.json to use that driver instead of the standard one: | ||
+ | < | ||
+ | echo ' | ||
+ | </ | ||
+ | |||
===== integrate changes from one branch into another branch ===== | ===== integrate changes from one branch into another branch ===== | ||
Line 128: | Line 165: | ||
</ | </ | ||
+ | ==== rebase remote branch (or original fork) with local branch ==== | ||
+ | |||
+ | add forked repo if none (git remote -v) | ||
+ | < | ||
+ | git remote add upstream https:// | ||
+ | </ | ||
+ | |||
+ | rebase remote on master | ||
+ | < | ||
+ | git fetch upstream | ||
+ | git checkout master | ||
+ | git merge upstream/ | ||
+ | git push | ||
+ | </ | ||
==== merge specific commit from branch to another ==== | ==== merge specific commit from branch to another ==== | ||
Line 152: | Line 203: | ||
</ | </ | ||
+ | ===== submodule ===== | ||
+ | |||
+ | < | ||
+ | cd < | ||
+ | git checkout master | ||
+ | git branch -u origin/ | ||
+ | cd < | ||
+ | git config -f .gitmodules submodule.< | ||
+ | </ |