Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added git push --force alias #36

Closed
wants to merge 1 commit into from

Conversation

kolyabres
Copy link

Useful alias when you need push your branch after "rebase" commands

@joelparkerhenderson
Copy link
Member

joelparkerhenderson commented Mar 29, 2018

Thanks for the suggestion! We deliberately do not alias --force flags because they are dangerous (e.g. destructive to smooth pulls by other stakeholders) and also should be very rare (e.g. only in exceptional circumstances when something has gone really wrong).

If you're using push --force often, can you help me understand how and when? I can likely show you a better way.

@kolyabres
Copy link
Author

Here is the flow where I use push --force

  • push your local branch
  • do git rebase on the local branch
  • do push --force for updating remote repo

@joelparkerhenderson
Copy link
Member

My advice is there's a better way.

This is because when someone does a push --force to a remote repo branch, the command destroys history, and can cause problems for anyone who's pulled the repo branch.

I has seen some teams use push --force in this way: a developer works on a local topic branch, then submits a pull request to GitHub; developers provide feedback using GitHub comments; the developer adjusts the local branch based on the feedback (such as squashing commits) then does a push --force to update the pull request.

Is that the kind of situation you're in? And/or can you explain more about your exact workflow and why you're doing a local rebase?

@kolyabres
Copy link
Author

I has seen some teams use push --force in this way: a developer works on a local topic branch, then submits a pull request to GitHub; developers provide feedback using GitHub comments; the developer adjusts the local branch based on the feedback (such as squashing commits) then does a push --force to update the pull request.

Yes, exactly.

@joelparkerhenderson
Copy link
Member

Good to know.

This kind of push --force workflow is a quick/dirty workaround for GitHub not providing a pull request revision capability.

A solution that is more robust is to do your rebase, then do a new pull request.

A solution that is more savvy is to have your team use topic aliases, such as topic-push, that do your team's workflow, and can contain a push force.

A solution that gives you what you want for you personally is to put your own alias in your git config file.

Lots of people have lots of opinions about force, and git in general, so what I'd like to do is have this issue open for a while in case people want to comment.

@joelparkerhenderson
Copy link
Member

Close because +2 weeks without new comments. Feel free to reopen if you have comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants