![]() If your colleagues change the remote repository after your last pull request, this flag will raise an error to prevent you from overwriting the new commits.įor more details and variants of the git push command, you can check the official documentation. Use the -force-with-lease flag instead of the -force flag. ![]() Use the git revert command if you need to correct a mistake that you may have pushed onto the remote repository. Therefore, the following safety rules should be kept in mind when using the git push -force -u origin command:ĭo not use the command on shared repositories unless you are certain your colleagues have not made any changes since your last pull request. If someone else makes a new commit to the remote repository that is not present in your local commit history, using the git push -force -u origin command will remove that commit. Since the git push -force -u origin command forcefully overwrites the commit history of the remote repository, its use is discouraged when working on shared repositories. Delete the branch on the remote: git push origin -delete master. origin saves you the trouble of writing out the entire remote repository URL when you need to push changes. Update the default branch name in your repository Verify that nothing is pointing to it. Origin: The origin option refers to an alias on your system for a remote repository URL Uniform Resource Locator. Tracking references can be used in argument-less commands, e.g., git pull. u: The -u flag creates a tracking reference for every branch that you successfully push onto the remote repository. One of the only times you should be force-pushing is when youve performed a local cleanup after youve pushed a private feature branch to a remote repository (. force: The -force flag is responsible for overriding the protective measures of the remote repository to ensure that your changes are forcefully pushed. The options in the git push -force -u origin command are described as follows:
0 Comments
Leave a Reply. |