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.
If someone else makes a new commit to the remote repository that is not present in your local commi5t history, using the git push --force -u origin command will remove that commit. Therefore, the following safety rules should be kept in mind when using the git push --force -u origin command:
-----
---
-
Do not use the command on shared repositories unless you are certain your colleagues have not made any changes since your last
pullrequest. -
Use the git revert command if you need to correct a mistake that you may have pushed onto the remote repository.
-
Use the
--force-with-leaseflag instead of the--forceflag. If your colleagues change the remote repository after your lastpullrequest, this flag will raise an error to prevent you from overwriting the new commits.
---
Comments
0 comments
Please sign in to leave a comment.