Nicolas's workshop

Git

August 20, 2022

Deleting a commit

The --soft flag ensures changes from the deleted commit remain staged:

git reset --soft HEAD~1

Rebasing to the tip of local main branch

git rebase main
git push --force-with-lease

In case there are conflict execute commands like git add ... and git rebase --continue

When relevant, priority can be given to feature branch changes with:

git rebase --main -Xtheirs

followed with:

git push --force

Updating the local branch with respect to remote

git pull --rebase

Interactive rebase

git log --oneline --decorate --all --graph
git rebase --interactive HEAD~3
git push --force origin feat/add-my-feature

Get back to older commit after several commits pushed to the remote

Use git log and git reflog to identify the commit to target and get its sha1, say COMMIT_HASH

Get back to that commit with:

git reset --hard COMMIT_HASH

Finally, push with:

git push origin feat/opensearch_operator --force-with-lease

Previous: Github

Next: Argo CD