Git & Repo 最基本命令 菜鸟教程

2021-04-22  本文已影响0人  fcf7850dd33e

前言:发现新来小伙伴,对git以及repo命令还不是特别熟悉,因此对git及repo最基本命令做了一下小结:

************************Repo*************************************

repo init -u ssh://git@gitlab...manifest.git -b [分支]

repo sync

repo status

repo branch

repo manifest 

repo diff

repo help

************************查看*************************************

1、查看本地分支

git branch

2、查看远程分支

git branch -r

3、查看所有分支

git branch -a

4、查看状态

git status

5、查看提交日志

git log

************************创建*************************************

本地创建新的分支

git branch [branch name]

切换到新的分支

git checkout [branch name]

创建+切换分支

git checkout -b [branch name]

************************删除*************************************

删除本地分支

git branch -d [branch name]

删除github远程分支 

git push origin :[branch name]

************************推送*************************************

将新分支推送到github

git push origin [branch name]

提交分支数据到远程服务器

git push origin <local_branch_name>:<remote_branch_name>

例如:

git push origin 2.0.1.20120806:2.0.1.20120806

远程分支和本地分支需要区分好,所以,在从服务器上拉取特定分支的时候,需要指定远程分支的名字。

git checkout --track origin/2.0.1.20120806

注意该命令由于带有--track参数,所以要求git1.6.4以上!这样git会自动切换到分支。

************************分支合并merge*************************************

git merge feature/login

git merge  damo_release_201020_feedingRank

************************tag*************************************

git tag 2.0.2

git push --tags

1、拉取远端指定的分支(本地不存在)

git fetch

git checkout -b 本地分支名 origin/远程分支名

2、创建本地分支,并推送到远端

(二).推送本地分支到远程仓库

git push --set-upstream origin 分支名

本地分支推送到远端:

repo forall -c git push ika damo_:damo_

本地分支与远端建立关联跟踪:

repo forall -c git branch --set-upstream-to=module/damo_  damo_

设置本地分支与远程分支的追踪:

git branch --set-upstream-to=origin/远程分支名 本地分支名

基于远端分支创建分支:

1、先fetch 远端的 ila_210120

repo forall -c git fetch ila ila_210120

2、基于远端的ila_210120创建  damo_ila_210120分支

 repo forall -c git checkout -b damo_ila_210120 ila/ila_210120

cherry-pick:(某一个commit

git cherry-pick f8857cbb08519b10981b0e2df999363ebfe8b6d3

push推送到远端

git push ila damo_ila_210120_review

强推:

git push --force ila 201140_newGuide_oneCommit

合成一个commit流程:

1、创建一个新分支:

2、reset到第一个commit:

3、重新commit:

reset区别:

repo forall -c git reset --hard

repo forall -c git reset --soft f8857cbb08519b10981b0e2df999363ebfe8b6d3

1、https://www.cnblogs.com/mmykdbc/p/9076063.html

2、https://blog.csdn.net/top_code/article/details/51931916

3、https://www.jianshu.com/p/bf7b09e234c8

4、template模板:https://blog.csdn.net/weixin_38019025/article/details/103951002

Control + C 退出终端执行的任务

6、电脑目录:

~/.

/Users/yuyahui

上一篇下一篇

猜你喜欢

热点阅读