git and repo基本操作

repo取版本
repo init -u "服务器URL" -m xxx/.../manifest.xml; repo sync 
repo start topic  project  创建话题
repo checkout topic  切换分支
repo status  查看分支 会例出每个版本/每个文件的状态
repo upload --re=jdoe --cbr -t . 
git config core.filemode false  禁止更改文件权限
git branch  查看分支
git status  查看当前分支以及repo xml指定的版本文件, 会例出每个版本/每个文件的状态
git checkout filename  从库上取出文件强制覆盖文件
git pull
git push
git add
git commit -m  some comments
git branch -d branchName
git cherry-pick <commit id> -s comments
git remote -v   查看远端分支
git push 服务器URL 版本 
git checkout -b v0.9rc1 origin/v0.9rc1  切换分支 
git log -p commitId  查看更改
git log file    查看文件的修改
git log --grep <patern>  根据关键字索引
git log --author


//删除没版本的文件
git add files
git reset --hard

查看远端仓库
git ls-remote -h git@10.22.52.217:/srv/sample.git

查看当前仓库的详细信息
git branch -vv

克隆指定分支:
git clone -b branchname  git@10.22.52.217:/srv/autoltp.git

克隆指定tag:
git clone --branch tagname  git@10.22.52.217:/srv/autoltp.git

创建git server 仓库
1. 创建git用户
2. sudo mkdir /srv/autoltp.git
3. sudo git init --bare /srv/autoltp.git
4. chown -R git:git /srv/autoltp.git


创建repo server 仓库
1. 创建一个有意义git 仓库;例如 autoltp.git 
2. sudo mkdir /srv/manifest.git 
3. sudo git init --bare /srv/manifest.git 
4. sudo chown -R git:git /srv/manifest.git 
下面是在客户端PC上的操作
5. cd /home/aouyang/work/
6. mkdir repotest
7. cd repotest
8. git clone git@10.22.52.217:/srv/manifest.git 
9. cd manifest
10. touch default.xml 
<?xml version="1.0" encoding="UTF-8" ?>

<manifest>
    <remote name="SVR86" fetch="." />
    <default remote="SVR86" revision="master" />
    <project path="autolt" name="autoltp" revision="master"/>

</manifest>
remote: name 服务器名字(随意)  fetch 仓库的相对路径
当前manifest仓库/srv/manifest.git   autoltp仓库/srv/autoltp.git;则fetch 相对于/srv/的路径
default: 默认获取的版本, project未指定revision时使用
project:path指定克隆到本地的相对路径; name指定仓库名
综上仓库为/srv/autoltp 
11. git add default.xml  git commit  git push origin:HEAD/master
12. cd /home/aouyang/work/repotest
13. repo init -u git@10.22.52.217:/srv/manifest.git 
14. repo sync 
15. cd autolt 
16. pwd
/home/aouyang/work/manifesttest/autolt


备份仓库
git clone --mirror git@10.22.52.217:/srv/autoltp.git
git remote update

创建远端分支
1. git branch localbranchname
2. git checkout localbranchname
3. git push origin localbranchname:remotebranchname

查看所有分支和TAG
git branch -a 


 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值