A practical guide to Git commands and workflows, covering configuration, submodules, squashing commits, reset operations, and GitHub credentials management
“git” can mean anything, depending on your mood. Source
configuration
Asking user and password every time: Make sure you are using ssh instead of HTTP protocol. See which one you are using with
git config -l
And if you need to update it, do it like this:
git config remote.origin.url git@github.com:alanboy/project.git
submodules
Git submodules
git submodule update --init --recursive
squash
git checkout yourBranch
git reset $(git merge-base master yourBranch)
git add -A
git commit -m "one commit on yourBranch"
reset
Git reset will move the HEAD and/or the branch pointer.
git reset --soft HEAD~5
Reset local repository branch to be just like remote repository HEAD
git fetch origin
git reset --hard origin/master
Note: HEAD~
means HEAD
minus 1 commits, HEAD~3
means HEAD
minus 3 commits.
git merge --squash users/alango/authz
Github and credentials
Install gh
:
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh
Then you can login using a PAT:
gh auth login
https://github.com/cli/cli/blob/trunk/docs/install_linux.md https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git
Internals
https://yurichev.com/news/20201220_git/
References
Amazing presentation: https://docs.google.com/presentation/d/1IQCRPHEIX-qKo7QFxsD3V62yhyGA9_5YsYXFOiBpgkk/view#slide=id.g4d6b1121f4_2_60
https://stackoverflow.com/questions/1628088/reset-local-repository-branch-to-be-just-like-remote-repository-head http://fabiensanglard.net/git_code_review/diff.php https://github.com/HerCerM/ManualDefinitivoGit/blob/master/Parte2_Profundizando.md https://pre-commit.com/ https://www.youtube.com/watch?v=Flho9VgaZ_g&ab_channel=javaM%C3%A9xico