目录
一、基本指令
1、下载代码
(1)下载远程库中的所有文件
git clone https://git.***.com/your/path/***.git
(2)下载远程库中指定分支的内容
git clone -b branchname https://git.***.com/your/path/***.git
以上的所有git地址最好选用HTTP地址
2、分支相关
(1)查看目前所在分支
git branch
(2)查看远程分支
git branch -r
(3)查看远程所有分支及状态
git branch -a
(4)新建分支
创建分支
git branch newbranchname
也可以创建的时候直接切换到新建的分支
git checkout -b newbranchname
(5)切换分支
git checkout branch_name
(6)删除远程分支
一般删除远程分支同时也要删除本地分支,分别运行一下命令:
git push remote_name -d remote_branch_name
git branch -d branchname
3、其他常用命令
(1)查看当前代码状态
这个命令可以查看当前本地代码和远程代码之间的差异文件
git status
(2)拉取远程端最新的代码
git pull
4、将本地代码提交到已有的project
(1)本地新建一个文件夹,命名随意
(2)下载远端代码
git clone https://git.***.com/your/path/***.git
但一般会指定下载某个分支,在该分支下开发
git clone -b branchname https://git.***.com/your/path/***.git
下载后需要先cd到projet文件夹内,在进行后续操作,

最低0.47元/天 解锁文章
1237






