Git commit hashes

	
	git log
	

we can use the git log command to view commit hashes. We just need the first 7 digits of a commit hash.


Git reset

Suppose we have just made a couple of commits on the master branch, but we actually meant to make them on a separate branch instead. To undo those commits, we can use git reset.

	
	git reset [commit-hash]
	

If we want to reverse commits that we haven't shared with others,we can use reset and no one will ever know!

git reset [commit-hash] will reset the repo back to a specific commit. The commits are gone

	
	git reset --hard [commit-hash]
	Example : 
		git reset --hard 0026739
	

If we want to undo both the commits AND the actual changes in our files, we can use the --hard option. for example, git reset --hard HEAD~1 will delete the last commit and associated changes.


Git revert

git revert is similar to git reset in that they both "undo" changes, but they accomplish it in different ways. git reset actually moves the branch pointer backwards, eliminating commits. git revert instead creates a brand new commit which reverses/undos the changes from a commit. Because it results in a new commit, you will be prompted to enter a commit message.

	
	git revert [commit-hash]
	

If we want to reverse some commits that other people already have on their machines, we should use revert.


Git Restore

git restore helps us with undoing operations. Suppose we have made some changes to a file since our last commit. we have saved the file but then realize we definitely do NOT want those changes anymore! To restore the file to the contents in the HEAD, use git restore

	
	git restore   => This command is not "undoable" If we have uncommited changes in the file, they will be lost!
	

git restore restores using HEAD as the default source, but we can change that using the --source option. For example, git restore --source HEAD~1 home.html will restore the contents of home.html to its state from the commit prior to HEAD. You can also use a particular commit hash as the source


git commit --amend

git amend helps us to change the author information for the very last commit.

	
	git commit --ammend --author="user-id < email-d > 

	git push [origin] [main]