Git – Basic++ Commands

#git log – shows the commits done on the repository along with commit id, statement, user and timestamp. More on git log and the options documented : https://www.atlassian.com/git/tutorials/inspecting-a-repository#git-log

Git_Log.JPG

#git revert <commit-id> – revert to old commit.. In the above screen shot there is “Delete pullrequestfile.txt” with commit-id “cc6ddb…..” which I’ve committed after deleting the file. Now I want to revert to get the file back.

Git_Revert.JPG

But what if you have updated a file and reverted to the old commit ?? what if you have updated a file and “git pull” fetches the updated file from remote repository ?? Git keeps track of file changes and if the file is updated raise a “merge conflict” and ask the user to resolve.

Git_Merge.JPG

# git reset –hard <commit-id> – discard current changes and go back to commit  with comit-id.

Git_Reset.JPG

Reference : https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s