Branches
Download a remote branch locally
git checkout -b <local-branch> origin/<remote-branch>
Clone a repo from a specific branch
git clone --branch <branchname> <remote-repo-url>
or
git clone -b <branchname> <remote-repo-url>
Rebase
Configuration
git config --global pull.rebase true
Split a previous commit into multiple commits
git rebase -i <commit hash>
Replace pick with edit in the relevant commit
git reset HEAD~
Add the affected files or code to the stage and commit the new commits.
Conclude with:
git rebase --continue
Find where the app broke
git bisect
If it trows this error: "fatal: invalid reference:" run: "rm .git/BISECT_*"
Configurations
Show configurations
git config --list
and where they have been defined (three levels: local, in the repository, global: per user, system: for all users of the system)
git config --list --show-origin
Set up your identity
git config --global user.name "Nome Cognome"
git config --global user.email "nome.cognome@esempio.it"
the same command launched without --global within a repository will configure a specific user only for that repository
Configure the main branch name
git config --global init.defaultBranch main
Changing the date of a commit
GIT_COMMITTER_DATE="Wed Sep 9 22:00 2020 +0530" git commit --amend --date="Wed Sep 9 22:00 2020 +0530"


