Different operations to perform for git repositories management
...
git clone <repo_name>
git add -A OR git add OR git add *.extension
Then add commit using command git commit -m "message"
check git logs to select the header you want to keep
git reset --hard NOTE: This will also remove the files from local directory
git fsck --lost-found
this will returned back to lastest commit now use git rebase
OR
git reset --hard
There are cases where rebase is not powerful enough. For example when you expect to face a lot of conflicts. In this case merge is a better solution:
git merge
If instead you had a few commits one after another but you just want to pick the last one, rebase and merge won’t do. They would bring the whole branch back in master. That’s a situation for cherry-pick.
git cherry-pick
Once you know how to recover from bad mistakes, you’ll find that Git is not only a very powerful tool, but also a very forgiving one. As opposed to a motocross.
The following commands will help you figure you way out of most bad situations:
git show git fsck −−lost-found git diff And these ones will actually get out of these bad situations:
git rebase git cherry-pick git merge git apply
Reference: [1] http://www.programblings.com/2008/06/07/the-illustrated-guide-to-recovering-lost-commits-with-git/