0

This image is the result of git log --oneline --name-status

I am having an issue with git. I made a simple python file in a git initialized folder. Then I added it and committed it. Then I edited it, added another csv file to the folder, and committed it again.

The problem is, when I check out to the previous commit ID, the changes I made were not found to be reverted back. The csv file still exists, and the changes in python file also persists.

But when I tried to commit it again, using the same statement as I did earlier, the changes reverted.

So guys, please explain what just happened here.

I am a beginner to programming world. So, I would like to know how stuff work, not just the solutions. Hope its ok.

ti7
  • 16,375
  • 6
  • 40
  • 68
  • 5
    Unfortunately it's hard to really tell without seeing the repository's history and the commands you actually ran. – AKX May 10 '21 at 18:59
  • I am really a newbie to git. Actually this is a folder I just created now. To check and do what I learnt. Its not having any history. and had not ran any commands. Just add and commit. Also there is a single branch. I am just starting out learning this. – Viswajith J May 10 '21 at 19:03
  • I think you should add the output of `git log --oneline` to the question. – eftshift0 May 10 '21 at 19:16
  • 1
    The most likely explanation is that you didn't do exactly what you think you did, and the only way we can prove or disprove that would be to see the ouput of you running the commands. At a minimum, show the log, and also the command you ran to checkout the previous commit ID. – TTT May 10 '21 at 19:17
  • .. or even better: `git log --oneline --name-status` – eftshift0 May 10 '21 at 19:17
  • It said I have to get 10 reputations to post an image and now I should add it as a link. So I added it. – Viswajith J May 10 '21 at 19:52
  • 3
    In general we prefer that you don't add *images* of text. Just post the text itself in your question, formatted as a code sample. – larsks May 10 '21 at 19:54
  • Sorry for not adding image along the question..., but as I said, I am new here and am unaware of the practices here... So please pardon me and give me more suggestions on how to post questions effectively. – Viswajith J May 10 '21 at 19:55
  • @larsks From now on I will take care of that. Thanks – Viswajith J May 10 '21 at 19:57
  • OK- the log looks as you described. Can you show the command you ran that isn't working? – TTT May 10 '21 at 21:10
  • Yes, it all looks correct to me. If you run: `git show` you should be able to see how the new file is added and the other one is modified. If you run `git checkout master~`, you should see that the csv file goes away and the python script is modified. – eftshift0 May 10 '21 at 21:19
  • say `git reflog`, does that show anything other than the two commits in your currently-checked-out history? It sounds like you made a detached commit and didn't realize it, that can be confusing for the uninitiated however useful it is to us weirdos. – jthill May 10 '21 at 23:25
  • To clarify, I'm asking you to show the command and output of your question, "The problem is, when I check out to the previous commit ID, the changes I made were not found to be reverted back." – TTT May 12 '21 at 16:42
  • @TTT I can't do it as it was 2 days before. But its was ``` >>>git checkout ``` the id was the id of first commit i made. I totally made 2 commits. – Viswajith J May 13 '21 at 05:01

0 Answers0