![]() git reset is a very powerful command that may cause you to lose work. Sometimes, a commit includes sensitive information that actually needs to be deleted. git revert is always the recommended way to change history when it's possible. It functions as an "undo commit" command, without sacrificing the integrity of your repository's history. Instead of deleting existing commits, git revert looks at the changes introduced in a specific commit, then applies the inverse of those changes in a new commit. Git revert is the safest way to change history with Git. A password, token, or large binary file may return without ever alerting you. (First, you would git pull if you were working on the same branch, and then merge, but the results would be the same.) This means that whatever was so important to delete is now back in the repository. The most common result is that your git push would return the "deleted" commit to a shared history. In dramatic cases, Git may decide that the histories are too different and the projects are no longer related. What do you think will happen when you try to push? When they push, they'll have to 'force push', which should show to them that they're changing history. Meanwhile, you keep working with the commit that the collaborator tried to delete. They continue new commits from the commit directly before that. But, they make a change that deletes the most recent commit. Imagine – You and another collaborator have the same repository, with the same history. What can go wrong while changing history?Ĭhanging history for collaborators can be problematic in a few ways.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |