3
I made a git push --force
, but I wish I had git push --force-with-lease
it is possible to reverse this?
3
I made a git push --force
, but I wish I had git push --force-with-lease
it is possible to reverse this?
4
If you haven’t ruined anyone’s work by pushing git --force - you don’t have to go back and do the other. If damaged, doing "force-with-Lease" doesn’t help either: he would only refuse to push.
All that the git push --force-with-lease
makes sure to overwrite some work that your local repository didn’t know about yet.
For example: if you make a git fetch
the push --force
and push --force-with-lease
are indistinguishable: the second is as destructive as the first.
git push --force
on the remote server (github/gitlab/bitbucket), they are no longer recoverable from there. Kaput! End! Dead! (except if the remote server is under your control and not a git hosting in the cloud). (I’ve already said it’s not good to use "git push --force"?)git push --force
back, and her work that was lost on the server is restored on the server. Agree that starting tomorrow you will use separate branches to work, and you can go to happy hour now;git reflog
. With this command you should be able to find the commit that was previously on the cloud server. She can now create a new branch with this commit by going back over-writing work - just copy the hash from the lost commit and do: git branch branch_restauracao <id-do-commit-perdido>
- ready, she will have a local branch, on her machine, with the work that had been over-written on the serverIn short, you probably don’t have to do anything. But it’s best to review your team’s practices to avoid "git push --force" - whether it’s "-with-Lease" or not.
git provides a lot of flexibility and different ways of working to really, the only point where it might be interesting to "push --force" is when you’re "rebasing" a branch - that is, updating a separate development branch from the master branch, but so that the master commits that occurred after the current development branch split are all in the "base", not as a separate commit within the current branch.
In practice, I have not yet worked with any real project that has a level of maturity and/or complexity of the branchs such that the "rebase" really if they were necessary - the use of "merge", avoiding rebase may well be enough, and avoid the "push force".
Otherwise, with the proper use of branchs and merge policies back into the main branch, I don’t see why to use "push --force"
Browser other questions tagged git github
You are not signed in. Login or sign up in order to post.
Actually no one touched this branch, just myself... but it’s okay, I didn’t mess anything up... :), I think I just lost the commit that I had deleted 2 files because it’s... I had to delete it again, but thanks!
– Ivan Ferrer
the script is already there in case someone gets in trouble -
– jsbueno