This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
git [2023/01/06 17:58] dblume Add mention you can pull --rebase if you feel lucky |
git [2023/03/21 09:54] (current) dblume |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== git ====== | ====== git ====== | ||
| - | Make the clone at the remote repository. | + | Make the clone of the remote repository. |
| < | < | ||
| Line 11: | Line 11: | ||
| </ | </ | ||
| - | Double checking the remote names... | + | If it's a huge repo, [[https:// |
| < | < | ||
| - | $ git remote | + | git clone \ |
| - | origin | + | |
| - | origin | + | -b main \ |
| - | upstream | + | --single-branch \ |
| - | upstream | + | --no-tags \ |
| + | | ||
| + | --recurse-submodules=os/components/toolchain \ | ||
| + | | ||
| + | git@fake.github.com:project/project.git | ||
| </ | </ | ||
| Line 48: | Line 52: | ||
| <code bash> | <code bash> | ||
| - | $ git fetch --all # TODO investigate why fetch | + | $ git fetch --all # Bring your copy of the remote up-to-date |
| $ git remote prune origin | $ git remote prune origin | ||
| </ | </ | ||
| Line 64: | Line 68: | ||
| $ git push --set-upstream origin new_branch | $ git push --set-upstream origin new_branch | ||
| + | ==== Creating a local branch from an existing remote ==== | ||
| + | |||
| + | After doing a fetch, and suppose " | ||
| + | |||
| + | $ git switch remote-branch | ||
| ==== Changing a local branch to a new remote branch ==== | ==== Changing a local branch to a new remote branch ==== | ||
| Line 132: | Line 141: | ||
| <code bash> | <code bash> | ||
| git pull --rebase | git pull --rebase | ||
| + | </ | ||
| + | |||
| + | ====== Applying changes in a stash to a changed file ===== | ||
| + | |||
| + | When '' | ||
| + | |||
| + | < | ||
| + | git stash show -p | patch -p0 | ||
| </ | </ | ||
| Line 177: | Line 194: | ||
| I could' | I could' | ||
| + | |||
| + | ====== Limit scope of huge repos ====== | ||
| + | |||
| + | Create a .gitconfig file at the base of your repo: | ||
| + | <file git .gitconfig> | ||
| + | [remote " | ||
| + | fetch = +refs/ | ||
| + | fetch = +refs/ | ||
| + | tagopt = --no-tags | ||
| + | </ | ||
| + | |||
| + | Or explicitly specify your flags: | ||
| + | <code bash> | ||
| + | git fetch --no-tags origin main | ||
| + | git pull --no-tags origin main | ||
| + | git submodule foreach git pull --no-tags origin main | ||
| + | </ | ||
| + | |||
| + | The submodule one is an optimization for the more general: | ||
| + | <code bash> | ||
| + | git submodule update --recursive | ||
| + | </ | ||
| ====== git vim mergetool on macOS ====== | ====== git vim mergetool on macOS ====== | ||