git init
git add <file>
, git commit -am "description"
git status
, git diff
, git log
git branch (branch)
, git checkout
, git merge <branch>
, git branch -d <branch>
, git tag <tag-name>
git reset --hard commit_id
git remote add origin <link>
, git clone <link>
git push -u origin master
, git push origin master
A portable version of basic commands (not by me): Git cheet sheet
Minimal commands for Git starter in command line interface
Enough commands for Git/GitHub
Let's begin!
git init
in right folder first.
git add <file>
git add "*.md"
git add .
to add all to commit.gitignore
file 可用来标记出不想被 git 记录的文件, 如 .pyc 文件git commit
need some details
git commit -m "the description of changes, will be shown in logs, so it's important"
git commit -am (or -a -m) "description"
commit all changes ONLY in files git has already managed. (i.e. not applied to files not added. so to apply all changes, using git add before git commit.)
git add and git commit
git status
git diff
git log
On deleting
git rm
deleting file do not deleting it in git.
git checkout
can be used for replacing files in working folder.
On resetting
git reset --hard commit_id
HEAD: this version HEAD^, HEAD^^, HEAD~100
normal commit id: commit 31dc03905a9866775fe45ac8ae22382c685ce66e
git log
to get commit id.
git reflog
to get to a later version.
Branching
git branch <branch name>
: list (without argument) and add new branch
git checkout
short command for branch and checkout: git checkout -b <branch name>
git merge <name>
: merge a branch to branch in use.
git branch -d <name>
: deleting a branch
branching with conflicts: need to add later
general branching strategy: master-dev-bugs & features
Tagging
git tag <tag-name>
From local to remote: git remote add origin <link>
; from remote to local: git clone <link>
; detals git remote -v
Push
first push: git push -u origin master
for later pushes: git push origin master