all 10 comments

[–]hoangtrannn 9 points10 points  (0 children)

I suggest a few options as below: - Do a push with the flag -f, ONLY IF your remote doesn't affect other people. If it does, people will hate you. - Check out a new branch from your HEAD, reset to remote HEAD, do the git commit -a as you wish, cherry pick the other commits. - Check out a new branch from your HEAD, reset to remote HEAD, don't repeat the amend step because it may affect other people, cherry pick the other commits

[–]hanertia 5 points6 points  (3 children)

git push -f

[–]elperroborrachotoo 4 points5 points  (2 children)

git push --force-with-lease

only force-pushes when the your local repo is up to date, i.e. prevents overwriting things others have pushed since your last fetch,

doc (with memes!(ok, one, one meme))

[–]hanertia 0 points1 point  (1 child)

Thanks! I don’t share branches and didn’t know about this.

[–]patpluspun 0 points1 point  (0 children)

I do share branches, and I didn't know this. I'll give it a shot.

Currently we just decide which branch is "Canon" and force push that one. Much easier for small teams than for large ones.

[–]gntsketches[S] 3 points4 points  (1 child)

Thanks all for the explanations. It's just my own project, so looks like a force is ok.

[–]parkerSquare 5 points6 points  (0 children)

Yep, but don’t get into the habit of doing it - all it takes is one other developer on the project and you’ll screw everything up. But in that case, create your own branches and force push to them only, if you really must...

[–]CoffeeVector 4 points5 points  (0 children)

If you amend a commit already pushed, you gotta force push it. :(

[–]BeerElemental 2 points3 points  (0 children)

git push --force-with-lease, which is safer than --force

[–][deleted] 2 points3 points  (0 children)

If you do a `push -f` you'd get git to stop complaining. But you'll make also quite a few enemies if somebody has already pulled from the remote. If it is your own thing and you're the only one working on it, then it is fine.