From 6a17a1eebc446f29d05b906fc9ee48bae2e4dfd4 Mon Sep 17 00:00:00 2001 From: Arjan Date: Fri, 13 Sep 2019 15:56:18 +0200 Subject: [PATCH] Update git cheatsheet Added some info about`git push --force-with-lease`, the lesser known/used sibling of `git push --force`. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 468d21c..39236bf 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,9 @@ To undo or discard commits, you can use `git commit -a --amend` to amend to previous commit (only if you haven't pushed yet). (Note: if you use `-a` it will include all staged changes, so you might want to `git status` first). ## git push force -`git push --force` will overwrite the status of the branch on the remote with your local status. +* `git push --force` will overwrite the status of the branch on the remote with your local status. + +* `git push --force-with-lease` is like `git push --force` with the additional check that the current status of the remote matches the local status for the remote. It helps in preventing you from deleting commits from other team members. **Note:** The original status on the remote will be **destroyed**. If anyone on the team has that branch locally, they'll need to delete it locally and checkout the branch again to get it in the same status as the remote.