git的简单使用,,。

好久没用git都差点忘完了,新公司太搞了,代码控制就是复制来复制去…
只好自己建库本地管理下。
基本概念:
工作区, 暂存区 , 本地仓库, 远程仓库

基本操作:
建仓库:
git init
设置属性:
git config -e user.name “XXX”
git config -e user.email ”XXX@qq.com"
这是库的属性 加上–global --system 可以分别设置用户和系统级别的属性

加文件到暂存区:
git add files/drectories
ex: git add test.txt

提交文件到本地仓库:
git commit -m “xxx”
git commit -F file
ex: echo “commit for test” > log
git commit -F log

克隆远程仓库代码:
git clone url

推送代码到远程仓库:
git push (origin branch : local branch)
推送前需设置:
远程仓库属性
git config receive.denyCurrentBranch “ignore”
同时远程本地仓库推送到远程仓库后,远程仓库需要git reset --hard才能得到最新的代码
本地仓库属性
git config --global push.default matching
这样即可push成功
拉取远程代码并合并
git pull
–2023.4.23.22:20

git本地仓库之间利用cherry-pick互相同步代码
在需要同步的代码里面设置远程仓库为被同步代码仓库
git remote rm origin
git remote add origin …/…/t40_2063_2205sdk-dev-v4.0_0605_ld
同步远程仓库
git branch --set-upstream-to=origin/<分支> t41_4g_dev
git fetch

git cherry-pick commit-id
–2023 06-08
gerrit代码review未通过修改方法
1.需要修改代码
git checkout commit id
修改
git commit --amend
重新提交
新建分支
git cherry-pick
2. 只改提交信息
git rebase -i
修改想改的commit 为edit,保存退出
修改
git commit --amend
重新提交
git cherry-pick commit…commit/…branch name
–2023 06-15

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值