This data loss is irreversible, so it's critical that we understand how –hard works with Git's three trees. Looking at the contents of test_file shows us that our latest text additions aren't present, and our new_test_file no longer exists. Undo Commits Undo last commit putting everything back into the staging area: git reset -soft HEAD Add files and change message with: git commit -amend -m. ![]() Git will tell us that the HEAD is now at the commit hash specified. Let's say we then decide to revert to the first commit in the repository. Option 2: Stages the Recent Commits Changes. ![]() Git commit -m "More text added to test_file, added new_test_file" The HEAD parameter tells git to reset the branch to the last commit. We'll lose a ny pending or uncommitted work in the staging index and working index.Īdding on to the example above, let's commit some more content to the file, and also commit a brand new file to the repository: echo "Text to be committed" > test_file Any previously pending changes to the staging index and working directory reset to match the state of the commit tree. After this, the staging index and working index reset to match that of the specified commit. ![]() The most dangerous and frequently used option with this invocation is commit history, as ref pointers update to the specified commit.
0 Comments
Leave a Reply. |