补丁:
单独针对某一个ccommit打patch:
git show *** > patch01.patch
git apply/git am 附件patch
打tag生成补丁:
git diff -a --src-prefix=$REPO_PATH/ --dst-prefix=$REPO_PATH/ tag1 tag2 2>&1 > patch.diff
patch -p1 < /home/patch.diff
常用:
git commit --amend //给最后一个commit加上id
git remote add -f caf
git remote remove caf//删除远程分支
git commit --author="*** <***@***.com>" -m
repo forall -c "git clean -d -f;git reset --hard HEAD" -j8
repo init -u ssh://192.168.8.***:***/android/.repo/manifests -b branch
repo sync -c -d -j8
git config --global --replace-all user.name
git config --global --replace-all user.email
根目录配置邮箱
repo forall -c git checkout -b **//创建新分支
repo forall -c 'git push ***' //提交创建的分支
repo forall -c 'git push caf ***' //提交创建的分支
repo forall -c 'git push caf --delete ***'
repo forall -c 'git branch -D ***'
git push caf --delete *** //删除远程分支
repo forall -c "pwd;git merge remotes/m/***" | tee repomerge.log //merge分支并记录log
repo回退到某tag:
先去随意git仓库下,git tag,假设想回退的tag号为XXX_HALO_2.1.2_L1_20181220
1)在android根目录下,新建分支,repo forall -c git checkout -b new_branch_xxx XXX_HALO_2.1.2_L1_20181220
2)此时所有仓库已创建好新分支new_branch_xxx,且已回退至tag为XXX_HALO_2.1.2_L1_20181220时间节点的历史版本
git 命令:
创建git
git init //在当前目录创建.git
git init workspace //在workspace目录下创建.git
git config --list //显示当前的 git 配置信息
编辑gitconfig:
git config -e //针对当前仓库
git config -e --global //针对系统上所有仓库
设置提交代码时的用户信息: //针对该用户配置
git config --global user.name "runoob"
git config --global user.email test@runoob.com //如果去掉 --global 参数只对当前仓库有效
git clone <repo> <directory>
repo:git 仓库,directory:本地目录
//如果要自己定义要新建的项目目录名称,可以在上面的命令末尾指定新的名字:
git clone git://github.com/schacon/grit.git mygrit //将名字改为mygrit
git remote set-url caf ssh://192.168.8.238:29418/TT/Andriod_12_POS/andriod
git init 初始化仓库
git clone 拷贝一份远程仓库,也就是下载一个项目
git add 添加文件到暂存区
git status 查看仓库当前的状态,显示有变更的文件
git diff 比较文件的不同,即暂存区和工作区的差异
git commit 提交暂存区到本地仓库
git reset 回退版本
git rm 将文件从暂存区和工作区中删除
git mv 移动或重命名工作区文件
git checkout 分支切换
git switch 更清晰地切换分支
git restore 恢复或撤销文件的更改
git log 查看历史提交记录
git blame <file> 以列表形式查看指定文件的历史修改记录
git remote 远程仓库操作
git fetch 从远程获取代码库
git pull 下载远程代码并合并
git push 上传远程代码并合并