总结自廖雪峰的Git教程
作者GitHub
$ git merge --no-ff -m "merge 2" dev
$ git log --graph --pretty=oneline --abbrev-commit
* a334548 (HEAD -> master) merge 2
|\
| * 24cb079 (dev) 10.22
|/
* 6e22ae1 (origin/master) second
* f98eabc add readme
* 2a1d1eb first comm
$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"
$ git init
Initialized empty Git repository in /Users/michael/learngit/.git/
$ git add 文件名
提交所有文件
$ git add .
$ git commit -m "对于本次提交的注解"
$ git status
$ git diff 文件名
$ git log --pretty=oneline
$ git reset --hard HEAD^
HEAD为当前版本 上上版本为HEAD^^
$ git reset --hard 版本号
$ git reflog
$ git checkout -- 文件名
$ git reset HEAD 文件名
$ git rm 文件名
$ git commit -m "信息"
$ git branch 分支名
$ git checkout 分支名
$ git checkout -b 分支名
$ git checkout -d 分支名
$ git branch
$ git merge 分支名
$ git log --graph
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: readme.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git stash
Saved working directory and index state WIP on dev: 5cf14e5 1
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
nothing to commit, working tree clean
$ git checkout -b issue-001
Switched to a new branch 'issue-001'
$ git add readme.txt
$ git commit -m "fix bug 001"
[issue-001 25c3a9a] fix bug 001
1 file changed, 1 insertion(+), 1 deletion(-)
$ git merge --no-ff -m"merge bug fix 001" issue-001
Merge made by the 'recursive' strategy.
readme.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
$ git stash list
stash@{0}: WIP on dev: 5cf14e5 1
$ git stash apply
On branch dev
Your branch is up to date with 'origin/dev'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: readme.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git stash drop
Dropped refs/stash@{0} (bcae8d1e5f93636a88d8497370e8ba006c302580)
$ git stash pop
$ git stash stash@{0}
$ git cherry-pick 25c3a9a29ffbb
[dev 86beb0a] fix bug 001
Date: Sat Aug 17 10:01:47 2019 +0800
1 file changed, 1 insertion(+), 1 deletion(-)
$ git remote
origin
$ git remote -v
origin [email protected]:wangzitiansky/learngit.git (fetch)
origin [email protected]:wangzitiansky/learngit.git (push)
wangzitiandeMacBook-Air:learngit myx$
$ git checkout -b branch-name origin/branch-name
$ git branch --set-upstream-to=origin/dev dev
$ ssh-keygen -t rsa -C "[email protected]"
$ git remote add origin 仓库地址
$ git push -u origin master
$ git push origin master
$git pull
$ fatal: refusing to merge unrelated histories
$ git clone 仓库地址