- git clone 将远程分支(master)代码拉到本地;
- git checkout 切分支;
- git checkout -b <分支名> 新建分支并切换到新建的分支;
- git branch 分支管理;
- git branch <分支名> 新建分支;
- git branch -d <分支名> 删除分支,使用“-D”强制删除;
- git branch -v 查看每一个分支的最后一次提交;
- git branch -vv 查看本地分支与远程分支的关联关系;
- git branch 查看分支;
- git branch --merged 查看已经合并到当前分支的其他分支;
- git branch --no-merged 查看所有未合并工作的分支
- git stash 暂存,保存当前分支的内容(不进行提交,用于临时保存切换到其他分支)
- git stash list 查看所有暂存;
- git stash pop 恢复最近的暂存内容,也可以在后缀增加“stash id”用于恢复指定的暂存;
- git stash drop [stash_id] 删除指定的暂存内容;
- git add 将文件加入库跟踪区;
- git commit 将库跟踪区改变的代码提交到本地代码仓库中;
- git commit -m “提交内容的描述信息”;
- git commit --amend 撤销提交
- git pull 其实就是 git fetch 和 git merge FETCH_HEAD 的简写(https://www.runoob.com/git/git-pull.html)
-
git pull <远程主机名> <远程分支名>:<本地分支名> 例:git pull origin master:brantest 拉取远程master分支与本地brantest分支合并。
-
- git push 将本地仓库中的代码推到远程仓库;
- git rm 从暂存区移除某个文件;
- git log 查看操作commit的历史;
- 退出,按q键;
- git fetch <remote> 从远程从库中抓取和拉取;
- git remote rename <原名称> <新名称> 对远程仓库重新命名;
- git merge <分支名> 合并指定分支到当前分支。
系统学习,请看:https://git-scm.com/book/zh/v2