Git笔记
git基本操作示意
-
fork project from Upstream
-
git init
-
git clone url
-
git fetch <upstream>/<upstream><branch>(从远程拉取所有更新到本地,非当前工作区,不会自动合并到当前工作分支,需人工合并)
-
git checkout -b newbranch upstream/branch(在upstream/branch的基础上创建新分支)
-
git merge upstream/branch(保留原节点)
git rebase upstream/branch(不留)
-
-
git pull upstream(远程拉取并自动合并至本地当前分支)
-
-
git add .
-
git commit -m "干了什么"
-
git push <remote-name> <branch-name>(同名分支)
git push <remote-name> <local-branch>:<remote-branch>(不同名分支)
工作区操作指令
撤销(可以只提交一部分并push到upstream)
git reset HEAD <file>从暂存区取消对该文件的提交
git rm --cached <file>从暂存区中删除文件,但是工作区依然还有该文件
git checkout --<file>撤销上一次对文件的操作
git diff <file-name>指定文件在工作区和暂存区上差异比较
暂存区操作指令
git commit -m "commit_info"
git commit -a -m "commit_info"
git commit --amend 撤销上一次提交
标签
git tag 列出现在所有的标签
git tag v1.5 创建一个轻量级标签
本地仓库操作指令
git remote add [remote-name] [url] 添加远程仓库
git remote rm [remote-name] 移除远程仓库