Tuesday, August 4, 2015

git commands fundamentals


What I have learned as Git basic commands
  • git init
  • git log
  • git status
  • git add 
  • git add -u
  • git commit -m "message for comming"
  • git diff HEAD~1..
  • git diff <#hash code>..<#hash code>
  • git clean (it is to delete files from system!)
  • .gitignore
  • git log origin/master
  • git branch -r
  • git pull origin branch
  • git commit -am "commit"  (no need to use "git add" as separate step)
  • git tag -a | git tag -s
  • git config --global alias.lga "log --graph --oneline --all --decorate"
  • git reflog (2nd trash bin - 30days by default only)
  • git stash | git stash list | git stash apply | git stash pop | git stash branch new_branch_for_stash(half way work, nor do want to commit, nor want to lose the modification)
  • git checkout (go to a branch or fetch latest file version)
  • git checkout master ; git merge feature1 (merge feature1 into master branch)
  • git diff --cached (compare repo and staging area)
  • git rebase (rebase the branches created from, conflicts might occur)
  • git cherry-pick (allow one commit and merge into)
  • git push origin master:new_branch (push master branch's changes up to origin's new_branch branch, ":new_branch" is optional if the branch name is the same as local branch)
  • git push origin  :remote_branch_name (delete remote branch should be done with caution, because other people might be working on top of it)
  • git log -p -1 <file or path> or git log -p <file or path>

No comments:

Post a Comment