Git 的常用命令

2017-08-22  本文已影响12人  喜欢书的女孩
菜鸟教程.png

每天到办公室,打开电脑,开启 android studio, 然后去冲一杯咖啡,回到座位,打开 Terminal. 更新一下本地代码(git pull),查看一下 pull request . 看完全部 pull request,领取 tickets, 去吃个午饭,中午打一场桌球,下午开始写代码,写完repect code , 提交(git commit , and then git push),下班(see you tomorrow)...

1. 版本控制系统是一类软件工具,可帮助软件团队管理源代码随时间的变化。

Git

2. 设置一个仓库

初始化新存储库 : git init
克隆现有存储库 : git clone
配置和设置 : git config

3. 保存和更改

将更改保存到存储库 : git add + git commit
检查存储库 : git status 、 git log

4. 撤销更改

切换分支:git checkout
还原更改:git revert
重置:git reset
清除:git clean

5. 重写历史

提交:git commit --amend
压缩节点:git rebase
git reflog

6. 检查存储库

查看git 状态:git status
查看git 记录:git log

7. 更换仓库

项目根目录:git bash   
重新设置url:git remote set-url origin http://gitlab.frp.gzido.com:8000/AR/ARMagicCup.git 

8. 同步

同步远程和本地:git fetch
拉到本地仓库:git pull
推到远程仓库:git push
  1. 完整的工作流程
<---First submitted successfully--->
$ cd /Users/emily/Documents/MyCode 
$ git config --global user.name "Emily Chen"
$ git config --global user.email emily@gmail.com
$ git init
$ git add .
$ git add.commit -m "first time commit"
$ git remote add origin https://github.com/yourGithubName/yourProjectName.git 
$ git push origin master
$ git push origin status
<---On another branch, make some change--->
$ git branch develop
$ git checkout develop
---do one ticket, and finished---
$ git add  update file
$ git commit
$ git push
<---Create a pull request--->
$ git request-pull v1.0 https://git.ko.xz/project develop
---do some change in this ticket, and finished---
$ git add  update file
$ git commit
$ git push
<---Merge into the master branch--->
$ git rebase
$ git push -f  develop
$ git merge
上一篇 下一篇

猜你喜欢

热点阅读