Created
July 27, 2016 22:53
-
-
Save koji/c903df3562bfa548c2db004da945fb95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git init #Initialize git repo | |
$ git add -A # Add everything | |
$ git commit -m "comment" | |
$ git commit # when hit this command, vi will be started to add comment to commit. Write something and save it. | |
$ git show = git show HEAD | |
$ git status #See a repo’s status | |
$ git log # Show commit logs | |
$ git log -p # git show HEAD+git show HEAD^+git show HEAD^^ | |
$ git log --oneline # brief version of git log | |
$ git checkout -b branch name # Create a new branch | |
$ git branch #list branches | |
$ git checkout master #switch from branch to master | |
$ git checkout branch name #switch from master to branch | |
$ git merge branch name # Merge master and a branch | |
$ git push | |
$ git branch -d branch name #Delete a branch | |
$ git remote -v #check remote settings | |
$ git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git #change remote url | |
$ git rm --cached filename # remove file from index | |
$ git rm filename # remove file from index and workspace | |
$ git log # show logs | |
$ git status | |
$ git commit -a -m "comment" # commit current index's file | |
$ git mv old_filename new_filename # rename | |
$ git commit -amend # commit the latest version | |
# ignore file | |
Method 1 | |
project/.gitignore | |
Method 2 | |
project/.git/info/exclude | |
Method 3 | |
$ git config --global core.excludesfile $HOME/.gitexclude | |
$ echo ".DS_Store" >> $HOME/.gitexclude | |
$ git revert commit-version # cancel specific commit, but there is still a log about the commit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment