0

In this post..

Checkout old commit and make it a new commit

git rm -r .
git checkout HEAD~3 .
git commit

I accidentally ran git checkout HEAD~3 rather than git checkout HEAD~3 .

What problem will this cause me? What is the purpose of the dot? If it is a problem, how do I fix it?

Lefty
  • 535
  • 6
  • 20
  • `.` represents the current folder. What problem are you having? – evolutionxbox Jul 26 '22 at 13:18
  • See `git help checkout`. Without the `.`, you have the `git checkout [-q] [-f] [-m] []` form. With the `.`, you have the `git checkout [-f|--ours|--theirs|-m|--conflict= – chepner Jul 26 '22 at 13:38
  • 1
    This may be a good reason to stop using `checkout` and start using the newer and equivalent `switch` and `restore` commands instead. With the new commands it's not possible to accidentally make this mistake. Although it was harmless in your case, going the other way could sometimes ruin your day. – TTT Jul 26 '22 at 14:17
  • Side note, a better way make a new commit which reverts the top X most recent commits, is [probably here](https://stackoverflow.com/a/1895095/184546). – TTT Jul 26 '22 at 14:25
  • I'm sure there are more duplicates, but `.` does not search well in google... – torek Jul 26 '22 at 23:55

0 Answers0