Skip to content

Suggest users to use --force-with-lease instead of --force #6805

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

Merged
merged 2 commits into from
May 28, 2021

Conversation

yeikel
Copy link

@yeikel yeikel commented May 26, 2021

Why:

Closes #6804

What's being changed:

force overwrites a remote branch with your local branch.

--force-with-lease is a safer option that will not overwrite any work on the remote branch if more commits were added to the remote branch

Read more : https://git-scm.com/docs/git-push

Check off the following:

  • I have reviewed my changes in staging (look for the deploy-to-heroku link in your pull request, then click View deployment).
  • For content changes, I have completed the self-review checklist.

Writer impact (This section is for GitHub staff members only):

  • This pull request impacts the contribution experience
    • I have added the 'writer impact' label
    • I have added a description and/or a video demo of the changes below (e.g. a "before and after video")

--force-with-lease is a safer and more recommended approach than --force


force overwrites a remote branch with your local branch.

--force-with-lease is a safer option that will not overwrite any work on the remote branch if more commits were added to the remote branch (by another team-member or coworker or what have you). It ensures you do not overwrite someone elses work by force pushing.

I think your general idea surrounding the command is correct. If the remote branch has the same value as the remote branch on your local machine- you will overwrite remote. If it doesn't have the same value- it indicates a change that someone else made to the remote branch while you were working on your code and thus will not overwrite any code. Obviously if there are additional commits in remote then the values won't be the same.

I just think of --force-with-lease as the option to use when I want to make sure I don't overwrite any teammates code. A lot of teams at my company use --force-with-lease as the default option for a fail-safe. Its unnecessary in most circumstances but will save you lots of headache if you happen to overwrite something that another person contributed to remote.

I'm sure you looked at the docs but there might be some more wordy explanation contained in here:

Read more : https://stackoverflow.com/questions/52823692/git-push-force-with-lease-vs-force
@welcome
Copy link

welcome bot commented May 26, 2021

Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label May 26, 2021
@janiceilene
Copy link
Contributor

@yeikel Thanks so much for opening a PR! I'll get this triaged for review ⚡

@janiceilene janiceilene added using git Content related to using git waiting for review Issue/PR is waiting for a writer's review and removed triage Do not begin working on this issue until triaged by the team labels May 27, 2021
Copy link
Contributor

@jmarlena jmarlena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yeikel Thanks for improving the docs with this PR!

Once all tests are green, this looks ready to ship. 🚢

@jmarlena jmarlena merged commit 34d66ec into github:main May 28, 2021
@github-actions
Copy link
Contributor

Thanks very much for contributing! Your pull request has been merged 🎉 You should see your changes appear on the site in approximately 24 hours. If you're looking for your next contribution, check out our help wanted issues

@jmarlena jmarlena self-assigned this May 28, 2021
@kenzodadon

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
using git Content related to using git waiting for review Issue/PR is waiting for a writer's review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use force with lease instead of force
4 participants