Git Cheatsheet
Local branch creation
git checkout main
git pull
git checkout -b illustration_workflow
Commit
git add compute_sessions.py
git commit -m "illustration du workflow"
Rebase on main
git checkout main
git pull
git checkout illustration_workflow
git rebase main
If we have conflicts, handle them manually
Push
git push -u --force-with-lease origin illustration_workflow
We can configure git to directly send the current branch without having to specify those arguement (simple "git push"):
git config --add --bool push.autoSetupRemote true
or for older git version:
git config --global push.default current
Reseting
git reflog
git reset HEAD@{index}
git reset --hard HEAD to delete permanently modifications made after HEAD
Add a small fix to last commit
git commit -am --amend --no-edit
Warning Only on local commit that have not been pushed ! To change only the commit message:
git commit --amend
Move the last commit from main to another branch
git checkout new_branch
git cherry-pick master
git checkout master
git reset HEAD~ --hard
Commentaires