名字和邮箱
Administrator@MS-MDPJLOXFILTY MINGW64 /e/program/loongson/vpp/vpp-20.05 (master)
$ git config --global user.name "liusicong"
Administrator@MS-MDPJLOXFILTY MINGW64 /e/program/loongson/vpp/vpp-20.05 (master)
$ git config --global user.email "liusicong@loongson.cn"
通过命令行创建一个新的版本库
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin ssh://liusicong@127.0.0.1:29418/Document.git
git push -u origin master
通过命令行推送一个已存在的版本库
git remote remove origin #删除原有的
git remote add origin ssh://liusicong@127.0.0.1:29418/Document.git
git push -u origin master
git生成patch
git format-patch -1 3ed7b54b82d4ef2d51430ce7600d9f8ec6c7f836 8958a6d43062b4938818ef2ac69ccff0a888cfd3
增加,注释
git add 文件
git commit
将某个文件回退到某个版本
checkout 对应版本。格式为
git checkout <hash> <filename>
git checkout 5f41f528e2501397317233f6d8dab4ee6d127316 drivers/uio/igb_uio.c
git 删除远程仓库的某次提交
删除上一次远程仓库的提交,修改上次提交的代码,做一次更完美的commit。
git reset commitId (注:不要带–hard)到上个版本
git stash 暂存修改
git push --force 强制push,远程的最新的一次commit被删除
git stash pop 释放暂存的修改,开始修改代码
git add . -> git commit -m "massage" -> git push
git 查看某个文件的修改记录
1. git log filename
可以看到fileName相关的commit记录
2. git log -p filename
可以显示每次提交的diff
git迁移
git push --mirror ssh://liusicong@127.0.0.1:29418/dpdk-20.11.git
命令查看git仓库地址
git remote -v
下载某个分支的代码
git clone -b yd_push1 git@github.com:yandan15/git_study.git
使用git format-patch生成所需要的patch:
当前分支所有超前master的提交:
git format-patch -M master
某次提交以后的所有patch:
git format-patch 4e16 --4e16指的是commit名
从根到指定提交的所有patch:
git format-patch --root 4e16
某两次提交之间的所有patch:
git format-patch 365a..4e16 --365a和4e16分别对应两次提交的名称
某次提交(含)之前的几次提交:
git format-patch –n 07fe --n指patch数,07fe对应提交的名称
故,单次提交即为:
git format-patch -1 07fe
创建新分支
git brach <name>
删除跟踪
git rm -r --cached [FILE]
git diff 忽略文件
git config diff.nodiff.command /usr/bin/true
vim .gitattributes
lib/*/Makefile diff=nodiff
.gitignore diff=nodiff
.gitattributes diff=nodiff
cscope.* diff=nodiff
tags diff=nodiff