Git¶
Source control.
Conventions¶
Development Workflow¶
How to¶
Core Git¶
- [[Alias]]
- Branch
- Commit
- Config
- conflict: git diff --check
- Diff
- Submodule
- Ignore
- pre-commit (pre-commit.com)
- reflog
- Stash
- Tag
Extras¶
- git-lfs
- GitKraken
- GitLens
Untracked files¶
List untracked files and dirs:
List modification times:
Remove untracked files and dirs:
Stash untracked files
Deal with Obsidian sync pulling changes (when you didn't make local changes)¶
Share via sneakernet¶
wget https://github.com/mbailey.gpg
gpg --import ./mbailey.gpg
# cd cloned git repo
git bundle create mbailey.bundle --all
gpg --recipient mike@example.com -e mbailey.bundle
# Send me mbailey.bundle.gpg
Check out file from specific commit¶
git checkout c5f567 -- file1/to/restore file2/to/restore
Checkout Remote Branch¶
git fetch --all
git switch origin/gh-pages # creates branch if missing and sets up tracking for git pull/push
Diff two arbitrary files using git diff (e.g. for gpg files)¶
git diff --no-index file1 file2
Change commit author¶
For the last N commits:
git rebase -i HEAD~N -x "git commit --amend --author 'Author Name <author.name@mail.example>' --no-edit"
Update forked github repo¶
git remote add upstream git@github.com:original-repo/goes-here.git
git fetch upstream
git checkout master
git rebase upstream/master
git push origin master --force-with-lease
gpg diff¶
https://gist.github.com/marceloalmeida/e6593b93b388cdf1dbc282dffd424d1b#file-readme-md
git config --global diff.gpg.textconv "gpg --no-tty --decrypt"
echo "*.gpg filter=gpg diff=gpg" >> .gitattributes
echo "*.asc filter=gpg diff=gpg" >> .gitattributes
Delete dangling commits¶
shallow clone¶
Less files and no .git dir:
git clone --depth=1 git://someserver/somerepo dirformynewrepo
rm -rf !$/.git
See also¶
- Git - user-manual (file:///usr/share/doc/./user-manual.html)
- Git - Community
man gittutorial
- Tech Talk Linus Torvalds on git - YouTube
- distributed
- https://gregoryszorc.com/blog/2021/05/12/why-you-shouldn%27t-use-git-lfs/
- performance
git stash pop
song by The Ramones Blitzkrieg Bop (2016 Remaster) - YouTube- How to Use Git Shallow Clone to Improve Performance Perforce (www.perforce.com)
- [[vscode-gitlens-open-on-remote]]