-
Notifications
You must be signed in to change notification settings - Fork 0
Git
Andrei Montchik edited this page Jul 1, 2024
·
17 revisions
- Create the source directory.
sudo apt install git
- Update the Git configuration:
git config --global user.email "andrei@montchik.net"; git config --global user.name "Andrei Montchik"; git config --global pull.rebase false; - Confirm that the config change was applied:
git config --list
- Add the SSH pubkey to GitHub account: https://github.com/settings/keys
- Check SSH access: ssh -vT git@github.com
- request to add your Git account as collabrator to GitHub repo
- Use SSH to clone GIT repos
- Show:
remote branches: git branch -r - Create:
- Create Local Branch: git checkout -b
- Push to remote repo: git push --set-upstream origin
- Branch from the commit: git checkout -b
- Check if remote branch exists: git branch -r | grep
- Remove:
- Local: git branch -d
- Remote: git push origin --delete
-
git remote prune originOrgit fetch origin --prune - Remove all untracked files: git clean -fdx
- File names only: git diff --name-only release/raptor
- Specific file: git diff release/raptor raptor-cgw/api/src/main/scala/com/gemini/raptor/cgw/api/DomainEntries.scala
- Between branches:
- git fetch
- git log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --graph --grep="CGW" 'origin/release/2022-07-06'...'origin/release/2022-07-20'
- Between commits:
git diff b509834813184d3be0f1e536ed9275ef2ec57610 80c88fb6c407135223644d0d99bb504d980bc4f1 --name-onlygit diff b509834813184d3be0f1e536ed9275ef2ec57610 80c88fb6c407135223644d0d99bb504d980bc4f1 cpp/bin/env
- Save: git stash push -m "my_stash"
- View: git stash list
- Pop: git stash pop --index
- Remove all stashed: git stash clear
- Add new files:
git add . - Discard the uncommitted change:
git checkout -- <filename> - Undo the last commit:
- Preserve the changes as uncommitted:
git reset --soft HEAD~1 - Discard the changes:
git reset --hard HEAD~1
- Preserve the changes as uncommitted:
- Undo a single fileL
git checkout [commit ID] -- path/to/file - Merge the specific commit:
git cherry-pick <commit id> - Check which branches contains the commit:
git branch -a --contains <commit id> - Show Last n commits:
git log --pretty-oneline | head -n - Show all files in the commit:
git show --pretty="" --name-only <commit id> - Show Commits containing the search line:
git log -S LegacyMessageHandler
- Configure: https://gemini-spaceship.atlassian.net/wiki/spaces/DEV/pages/858859/Developer+Setup#DeveloperSetup-commit-signingGitCommitSigningConfiguration
- Troubleshoot: https://gemini-spaceship.atlassian.net/wiki/spaces/DEV/pages/2323644429/Commit+signing+troubleshooting
- Restart SSH Agent: killall ssh-agent; eval
ssh-agent -s; /usr/bin/ssh-add -s /usr/local/lib/opensc-pkcs11.so - Disable GPG signing: git config --global commit.gpgsign false
- Make sure that the signing is enabled:
git config --global commit.gpgsignshould returntrue
Merge from the remote branch: git merge --no-edit origin/master git merge --no-ff --no-commit -s recursive -X patience origin/release/raptor
Use git push --force-with-lease instead of git push --force to update a branch where you have changed history.
https://git-scm.com/book/en/v2/Git-Basics-Tagging
git tag -a -m git push origin to review: git show to checkout: git checkout