Change your current branch to point to the older commit instead.(You can find that via git log or any history browser.) You then have a few different options depending on exactly what you want to do: So, suppose the good commit that you want to go back to is f414f31. HEAD points to your current branch (or current commit), so all that git reset -hard HEAD will do is to throw away any uncommitted changes you have. Then make the files in your working tree and the index ("staging area") the same as the versions committed in.Make your current branch (typically master) back to point at.How do I then revert the files on my hard drive back to that previous commit? When I want to revert to a previous commit I use: git reset -hard HEAD And git returns: HEAD is now at 820f417 micro In your question you then go on to ask the following: (for example, even if you do git add to stage a new version of the file, that overwrites the previously staged version of that file in the staging area.) Once you've created a commit which has your project files in a particular state, they're very safe, but until then Git's not really "tracking changes" to your files. Git only records the state of the files when you stage them (with git add) or when you create a commit. So I know that Git tracks changes I make to my application, and it holds on to them until I commit the changes, but here's where I'm hung up: For safety, you should always check that the output of git status is clean (that is, empty) before using it. First, it's always worth noting that git reset -hard is a potentially dangerous command, since it throws away all your uncommitted changes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |