Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

accidentally committed in git [duplicate]

Tags:

git

Possible Duplicate:
Git undo last commit

I have a folder structure like this..

~/git
     ......all repos of my github account
     .....play
     .....emacs.d
     .....dummy
     .....etc

i have created dummy repo to get familiar with git commands. so instead of initializing dummy folder,i have issued git init in git folder and issued git add . ,and committed to my local repo.

I want to go back to my previous state,and do not want to loose any changes i have done. How can i do that?

like image 224
Srinivas Reddy Thatiparthy Avatar asked Dec 28 '11 16:12

Srinivas Reddy Thatiparthy


People also ask

How do I remove a commit?

Removing the last commit To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.

What is git Double commit?

When you save and exit the editor, Git applies all two changes and then puts you back into the editor to merge the three commit messages: # This is a combination of commits. # The first commit's message is: Removed most clearfixs in templates # This is the 2nd commit message: Removed most clearfixs in templates.

Does cherry-pick duplicate commits?

The reason why you should use cherry-pick rarely is that it easily creates "duplicate" commits: when you integrate a commit into your HEAD branch using cherry-pick, Git has to create a new commit with the exact same contents. It is, however, a completely new commit object with its own, new SHA identifier.


1 Answers

I assume your ~/git folder was no git repo before? Simply delete the .git folder and everything is like it was before.

All repos (play, emacs.d etc) still have their individual .git folders and are complete repos..

The only thing you did was init another git repo that is now also tracking the other repositories (including their .git folder contents)

like image 129
Tigraine Avatar answered Sep 22 '22 04:09

Tigraine