温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Git-命令

发布时间:2020-07-01 08:46:40 来源:网络 阅读:1164 作者:_追随我心 栏目:软件技术

写在前面的话:

GitHub是个git仓库(相当于Git服务器),安装在远程服务器端。

git是一个客户端工具,安装在用户的电脑上,用户通过git命令从GitHub上pull和push数据。

 

Git工作原理图

Git-命令

Git-命令


 资料地址:

  1. http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html

  2. http://www.cnblogs.com/springbarley/archive/2012/11/03/2752984.html

 

Windows上需要安装git客户端(git是命令行工具|GitHub是代码仓库)

 

remote:远程

repository :仓库

checkout:检出

 

 

mkdir  makefile   新建目录

cd  makefile

git init 初始化本地仓库

touch readme.txt  新建文件

git add readme.txt 添加文件到暂存区

git commit -m "first comomit"  提交文件到本地仓库,first comomit为备注

 

在本地仓库添加一个远程仓库

git remote add origin git@git.yongche.org:yinyongjie/git-test.git

 

git push 或者 git push -u origin master 提交文件到远程仓库

 

从远程仓库删除文件:

git rm --f "文件名"

git commit -m "delete file"     备注:delete file为备注,可以随便写 

git push

 

git强制覆盖本地:

git fetch --all

git reset --hard origin/master

git pull 或者 git push -u origin master

 

git branch 查看所有本地分支

git branch -r 查看所有远程分支

git branch -a  查看所有本地和远程分支

 

git branch -d master1  删除本地的分支名master1

 

git branch baidu 创建baidu分支

git checkout baidu 切换到baidu分支

git checkout – 切换到上一个分支

git checkout –b yidao 创建yidao分支并立即切换到yidao分支

 

git push origin yidao 把本地分支yidao push到远程分支

git push origin yidao:master 提交本地yidao分支到master分支(合并分支)

 

git merge master_team 把主分支合并到当前分支

 

git clone git@git.yongche.org:mayi/BackendAutoTesting.git   克隆代码到本地

 

git checkout . (取消所有本地的修改)

git log (查看提交历史) 按q键退出

git status

 


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI