- git branch 查看当前所属分支
- git branch -a 查看当前分支列表
(图1)
- 新建分支
(图2)
- 切换分支
(图3)
- git branch -a 查看当前分支列表
(图4)
- 把新分支提交到远程仓库上
(图5)
(图6)
- 删除分支
(图7)
- 查看分支
(图8)
- 删除远程仓库分支
(图9)
- 刷新后结果
(图10)
git常用命令
工程准备: git init / git clone
新增/删除/移动文件到暂存区:git add / git rm / git mv
查看工作区:git status
比较两个节点的差异:git diff
提交更改的文件 git commit
注意:提交是本地的动作,提交要说明提交信息,简述提交的内容让别人清楚, 不要忘记了-m
$git commit file_name -m "commit message"
查看日志:git log
推送远端仓库 git push
区别:
从暂存区到本地版本库:git commit
将本地版本库的分支推送到远程服务器对应的分支:git push
$ git push origin branch_name # 远端服务器上的分支名和本地的分支名相同
$ git push origin branch_name:new_branch_name#本地分支名为branch_name推送到远端后为new_branch_name
查看当前所属分支:git branch
查看当前分支列表:git branch -a
新建分支:git branch branch_name
切换分支:git checkout branch_name
删除本地分支:git branch -d branch_name
删除远程分支:git push origin --delete branch_name
从服务器中获取分支的更新,同时与本地指定分支自动合并:git pull
从服务器中获取分支的更新,不与本地分支合并:git fetch
把branch_name 上与当前分支之间存在差异的部分合过来:git merge branch_name
git reset用于撤销工作区中的git add / commit 等操作 将工作区内容退回到历史节点。reset 完以后要推送到远端使用命令:$ git push -f
用于回退本地所有修改但未提交的文件内容:git checkout .
有关git就了解到这吧,等我有兴趣了再学习这个吧:)