git & repo 命令总结

1.git stash 可用来暂存当前正在进行的工作, 比如想pull 最新代码, 又不想加新commit, 或者另外一种情况,为了fix 一个紧急的bug, 先stash, 使返回到自己上一个commit, 改完bug之后再stash pop, 继续原来的工作。
基础命令:

$git stash
$do some work
$git stash pop

进阶:
Git stash save “work in progress for foo feature”
当你多次使用’git stash’命令后,你的栈里将充满了未提交的代码,这时候你会对将哪个版本应用回来有些困惑,

’git stash list’ 命令可以将当前的Git栈信息打印出来,你只需要将找到对应的版本号,例如使用’git stash apply stash@{1}’就可以将你指定版本号为stash@{1}的工作取出来,当你将所有的栈都应用回来的时候,可以使用’git stash clear’来将栈清空。

git stash          # save uncommitted changes
# pull, edit, etc.
git stash list     # list stashed changes in this git
git show stash@{0} # see the last stash 
git stash pop      # apply last stash and remove it from the list

git stash --help   # for more info

2.当repo upload之后,本地又有一些修改想合并到前一个提交上,可以git commit -a --amend 然后repo upload就会自动合并到上一个提交上。
3. 当刚repo init和repo sync下来一个sdk后,需要运行repo start dev --all来统一创建名为dev开发分支,用repo 来统一管理。
4. 用repo来管理code时,一般需要从google的源来下载repo的code, 但是国内上google源一般很难,所以可以设置repo sync时的url, 可以设置本单位的源,这样就会很方便,这个url通过环境变量设置:
REPO_URL=ssh://local_server_url:port/toos/repo.git. 为了长期设置,可以将这个写入~/.bash_profile里面,就可以长期自动设置了。这个环境变量使用的地方在.repo/repo文件里面:

REPO_URL = os.environ.get('REPO_URL', None)                                                                                                                                                                    
if not REPO_URL:
   REPO_URL = 'https://gerrit.googlesource.com/git-repo'

可以看到,如果没有设置这个环境变量,则会设置google的默认url.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值