From f7497e17df26961ac8fab529470aa9df6ef4080e Mon Sep 17 00:00:00 2001 From: Ethan Palm <56270045+ethanpalm@users.noreply.github.com> Date: Fri, 19 Nov 2021 16:10:13 -0800 Subject: [PATCH] Document implications of a force-push to a PR's head branch (#23023) * Explain force push cautions * add a sentence * Explain necessity of force push * More accurate noun --- .../removing-sensitive-data-from-a-repository.md | 4 ++-- .../about-pull-requests.md | 2 +- .../commit-exists-on-github-but-not-in-my-local-clone.md | 2 +- .../about-protected-branches.md | 2 +- .../managing-a-branch-protection-rule.md | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/content/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository.md b/content/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository.md index fcd90269b564..9056bc0961cc 100644 --- a/content/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository.md +++ b/content/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository.md @@ -50,7 +50,7 @@ To replace all text listed in `passwords.txt` wherever it can be found in your r $ bfg --replace-text passwords.txt ``` -After the sensitive data is removed, you must force push your changes to {% data variables.product.product_name %}. +After the sensitive data is removed, you must force push your changes to {% data variables.product.product_name %}. Force pushing rewrites the repository history, which removes sensitive data from the commit history. If you force push, it may overwrite commits that other people have based their work on. ```shell $ git push --force @@ -124,7 +124,7 @@ To illustrate how `git filter-repo` works, we'll show you how to remove your fil > 1 files changed, 1 insertions(+), 0 deletions(-) ``` 6. Double-check that you've removed everything you wanted to from your repository's history, and that all of your branches are checked out. -7. Once you're happy with the state of your repository, force-push your local changes to overwrite your repository on {% ifversion ghae %}{% data variables.product.product_name %}{% else %}{% data variables.product.product_location %}{% endif %}, as well as all the branches you've pushed up: +7. Once you're happy with the state of your repository, force-push your local changes to overwrite your repository on {% ifversion ghae %}{% data variables.product.product_name %}{% else %}{% data variables.product.product_location %}{% endif %}, as well as all the branches you've pushed up. A force push is required to remove sensitive data from your commit history. ```shell $ git push origin --force --all > Counting objects: 1074, done. diff --git a/content/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests.md b/content/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests.md index 6531ae0ad6ed..04002cc4a88e 100644 --- a/content/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests.md +++ b/content/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests.md @@ -21,7 +21,7 @@ topics: **Note:** When working with pull requests, keep the following in mind: * If you're working in the [shared repository model](/pull-requests/collaborating-with-pull-requests/getting-started/about-collaborative-development-models), we recommend that you use a topic branch for your pull request. While you can send pull requests from any branch or commit, with a topic branch you can push follow-up commits if you need to update your proposed changes. -* When pushing commits to a pull request, don't force push. Force pushing can corrupt your pull request. +* When pushing commits to a pull request, don't force push. Force pushing changes the repository history and can corrupt your pull request. If other collaborators branch the project before a force push, the force push may overwrite commits that collaborators based their work on. {% endnote %} diff --git a/content/pull-requests/committing-changes-to-your-project/troubleshooting-commits/commit-exists-on-github-but-not-in-my-local-clone.md b/content/pull-requests/committing-changes-to-your-project/troubleshooting-commits/commit-exists-on-github-but-not-in-my-local-clone.md index 4495c5718864..613caee543d2 100644 --- a/content/pull-requests/committing-changes-to-your-project/troubleshooting-commits/commit-exists-on-github-but-not-in-my-local-clone.md +++ b/content/pull-requests/committing-changes-to-your-project/troubleshooting-commits/commit-exists-on-github-but-not-in-my-local-clone.md @@ -84,7 +84,7 @@ $ git fetch upstream recover-B ## Avoid force pushes -Avoid force pushing to a repository unless absolutely necessary. This is especially true if more than one person can push to the repository. +Avoid force pushing to a repository unless absolutely necessary. This is especially true if more than one person can push to the repository. If someone force pushes to a repository, the force push may overwrite commits that other people based their work on. Force pushing changes the repository history and can corrupt pull requests. ## Further reading diff --git a/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches.md b/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches.md index b36d6296c053..6353932fb491 100644 --- a/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches.md +++ b/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches.md @@ -157,7 +157,7 @@ You can only give push access to a protected branch to users, teams, or installe ### Allow force pushes -By default, {% data variables.product.product_name %} blocks force pushes on all protected branches. When you enable force pushes to a protected branch, anyone with at least write permissions to the repository can force push to the branch, including those with admin permissions. +By default, {% data variables.product.product_name %} blocks force pushes on all protected branches. When you enable force pushes to a protected branch, anyone with at least write permissions to the repository can force push to the branch, including those with admin permissions. If someone force pushes to a branch, the force push may overwrite commits that other collaborators based their work on. People may have merge conflicts or corrupted pull requests. Enabling force pushes will not override any other branch protection rules. For example, if a branch requires a linear commit history, you cannot force push merge commits to that branch. diff --git a/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule.md b/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule.md index 29936ab6fe09..af1d2efacac6 100644 --- a/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule.md +++ b/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule.md @@ -104,7 +104,7 @@ When you create a branch rule, the branch you specify doesn't have to exist yet ![Branch restriction checkbox](/assets/images/help/repository/restrict-branch.png) - Search for and select the people, teams, or apps who will have permission to push to the protected branch. ![Branch restriction search](/assets/images/help/repository/restrict-branch-search.png) -1. Optionally, under "Rules applied to everyone including administrators", select **Allow force pushes**. +2. Optionally, under "Rules applied to everyone including administrators", select **Allow force pushes**. For more information about force pushes, see "[Allow force pushes](/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches/#allow-force-pushes)." ![Allow force pushes option](/assets/images/help/repository/allow-force-pushes.png) 1. Optionally, select **Allow deletions**. ![Allow branch deletions option](/assets/images/help/repository/allow-branch-deletions.png)