“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"

Source

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

Rebase from origin main without switching branches

You can rebase your current branch on top of the latest origin/main without checking out main locally:

git fetch origin
git rebase origin/main
git push --force-with-lease

Prefer --force-with-lease over --force: it refuses to overwrite the remote if someone else pushed to your branch since your last fetch, so you won’t accidentally clobber a teammate’s commits.

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