User Tools

Site Tools


git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git [2023/01/23 15:23]
dblume
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.
  
 <code> <code>
Line 9: Line 9:
 <code> <code>
 git remote add upstream git://github.com/icambridge/get-shit-done git remote add upstream git://github.com/icambridge/get-shit-done
 +</code>
 +
 +If it's a huge repo, [[https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/|consider blobless and single branch and no tags]], like so...
 +
 +<code>
 +git clone \
 +  --filter=blob:none \
 +  -b main \
 +  --single-branch \
 +  --no-tags \
 +  --shallow-submodules \
 +  --recurse-submodules=os/components/toolchain \
 +  --recurse-submodules=':(exclude)**/porting_kit:' \
 +  git@fake.github.com:project/project.git
 </code> </code>
  
Line 54: 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 "origin/remote-branch" exists, then just:
 +
 +  $ git switch remote-branch
 ==== Changing a local branch to a new remote branch ==== ==== Changing a local branch to a new remote branch ====
  
Line 122: Line 141:
 <code bash> <code bash>
 git pull --rebase  # --dry-run to test first git pull --rebase  # --dry-run to test first
 +</code>
 +
 +====== Applying changes in a stash to a changed file =====
 +
 +When ''git stash apply'' doesn't work: Show the stash changes and pipe that to patch. Now you have a patch you can apply.
 +
 +<code>
 +git stash show -p | patch -p0
 </code> </code>
  
Line 183: Line 210:
 git pull --no-tags origin main git pull --no-tags origin main
 git submodule foreach git pull --no-tags origin main git submodule foreach git pull --no-tags origin main
 +</code>
 +
 +The submodule one is an optimization for the more general:
 +<code bash>
 +git submodule update --recursive  # Add --init before --recursive on first time
 </code> </code>
  
git.1674516215.txt.gz ยท Last modified: 2023/01/23 15:23 by dblume