

you have not changed the history of the project but added to it => when you perform git push all is good

this means you create a new node in the commit tree, i.e. revert: creates a new commit which is basically the opposite diff of the one created by the commit you are reverting (you'll see it in the automatic commit message).Regarding the part where you asked to get back to a older state there are 2 ways: That is the way git keeps track of your changes (and you can check it with the log command, or in the GUI tree view of the history, not sure how its called since i dont use GUI for git) git folder in the repository and assigns a hash to that change. To answer your 1st question: after you run the commit command the file gets saved on your hard disk a s a normal file, but git also saves the diff of the change in the. Make sure you only use it to get rid of commits that haven't been pushed to another repository! This can cause some serious headaches if any of those lost commits have been pushed to a public repository. Ī note of warning that git reset will alter history - if I made several commits and then reset to the first commit, the subsequent commits will no longer be in the commit history. With the -hard option, it replaces the contents of your working directory with what was on. If you want to set your branch to the state of a particular commit (as implied by the OP), you can use git reset, or git reset -hard The first option only updates the INDEX, leaving files in your working directory unchanged as if you had made the edits but not yet committed them. It's more or less a way to 'undo' a commit and save that undo in your history as a new commit. I want to tag both commits to help me treat this bug in a systematic way.The above answer is not quite correct - git revert does not set your repository to that commit - git revert creates a new commit that undoes the changes introduced by commit.

GIT TAG OLD COMMIT SOFTWARE
**Why do I want to tag the two older commits? Because there is some silent error (inconsistency with previous software I wrote in MATLAB) that I am trying to debug, and it is being caused by either one of two scripts (changes.py and dnds.py) and each has a different commit (cfa84db and 45b3a4d8) pointing to it. So I have started to make changes to changes.pyĬommit 45b3a4d83eece8a5adcb947392f15a14bd4b0e63Īuthor: *foo (I did not want to show personal information)* Tagger: *foo (I did not want to show personal information)*Īfter testing dnds.py by comparing whole-seq dN/dS output to MATLABs dnds() output, both using NG, dnds.py seems to have a calculation error. Now in both cases I get the following error: fatal: tag 'matlabTest' already existsīut when I show the 'matlabTest' flag by entering git show matlabTest I see that only the first commit was successfully tagged, I have truncated output since it is long, but at the end of the output I cannot see that both commits were tagged: tag matlabTest Specifically, the top and middle commit of the three shown above. I create a tag git tag -a matlabTest and now I want to add "matlabTest" to two of the commits**. I enter git log -pretty=oneline, showing three commits: cfa84dbb6dd3c2c9956421e723d2f99786f7b417 Preparing to make changes to changes.py to fixĤ5b3a4d83eece8a5adcb947392f15a14bd4b0e63 Tests: wholeseq analysis differs to MatlabĪ894da22e2eb1c03930829622656ffd6da5ce161 Initial python scripts for analysis I have followed the guidelines in the git book:, and here's what I tried (and failed): It seems Git wants to just create a new tag rather than linking the tag to the commits? (see below for more detail). Instead I am getting: fatal: tag 'matlabTest' already exists Why can I not add a tag to two older commits? git tag -a matlabTest cfa84dbb6dd3c2c9956421e723d2f99786f7b417
