Most frequently used git commands

If you have done so many unnecessary changes in different files and now you want to discard all the changes ( before working at cool mind ) : git reset --hard Another most used command that is very useful when did commit but that was a mistake. What will you do? If you want to remove your last commit that has not been pushed yet: git reset --hard HEAD^ If you want to see the comments of previous commits: git log To view unpushed git commits git log origin/master..HEAD To see the list of remote branch names git branch -r To create a local branch that will track remote branch git checkout -t origin/branchname To see all commits of someone git log --author=Jon To see the diff of a file which has already been added to stage git diff --cached example.txt Ref: http://stackoverflow.com/questions/1587846/how-do-i-show-the-changes-whi... Push to remote branch git push -u origin feature/branchname Change the remote tracking branch git branch --set-upstream master origin/master

Share this post

Leave a comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.