Git

一、Git基础命令
1、仓库克隆
git clone 项⽬远程仓库地址 # 拷⻉⼀份远程仓库,也就是下载⼀个项⽬
eg:
git clone https://gitlab..cn//** # 当前⾃动化项⽬git远程仓库地址
2、分⽀查看及切换
git branch -a #查看本地和远程仓库所有分⽀
git checkout 需要切换的分⽀名称 #分⽀切换
eg:
git checkout finance # ⽬前⾃动化项⽬开发分⽀为finance
3、下载远程代码并合并
git pull origin 分⽀名称
eg:
git pull origin finance # 取回 origin/finance 分⽀,再与本地的 finance 分⽀合并
4、添加⽂件到仓库
git add 需要添加的⽂件
eg:
git add test.py # 前提⼯作已进⼊项⽬路径
eg1:
项⽬路径:/Users/hp/Documents/tuhu_test
需要提交的⽂件路径为:/Users/hp/Documents/tuhu_test/Config_Files/test_data_tuhutest.yaml
命令⾏所处路径为:/Users/hp/Documents/tuhu_test
添加命令为:git add Config_Files/test_data_tuhutest.yaml
eg2:
项⽬路径:/Users/hp/Documents/tuhu_test
需要提交的⽂件路径为:/Users/hp/Documents/tuhu_test/Config_Files/test_data_tuhutest.yaml
命令⾏所处路径为:/Users/hp/Documents/tuhu_test/Config_Files
添加命令为:git add test_data_tuhutest.yaml
注:add后的内容取决于当前命令⾏所处路径
5、添加提交说明
git commit -m 提交说明
eg:
git commit -m '增加UI⽤例'
6、提交本地⽂件⾄远程仓库
git push origin 需要提交的分⽀
eg:
git push origin finance # 将本地的分⽀版本上传到远程并合并
7、完整提交⼀次⽂件⾄远程仓库
(1)进⼊仓库⽬录
cd /Users/hp/Documents/tuhu_test # 检查当前分⽀是否是你需要提交的分⽀,如命令⾏⼯作⽬录已是仓库⽬录⽆需此操作
(2)同步远程仓库代码
git pull origin finance # 每次提交前同步下远程仓库代码,避免本地分⽀不是最新代码
(3)添加⽂件到仓库
git add test.py # test.py⽂件路径:/Users/hp/Documents/tuhu_test/test.py
(4) 提交说明
git commit -m "⽂件提交测试说明"
(5) 推送⾄远程仓库
git push origin finance
二、git拉取代码存放位置

posted @ 2020-12-08 21:25  牒_MINER  阅读(87)  评论(0)    收藏  举报