做法:
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
安装:
sudo apt install tig
1.到本地仓库 cd
2.查看状态:git status
3.添加文件:git add .
4.提交 git commit -m"备注"
5.查看日志:git log
6.查看当前分支:git branch
7.拉取最新代码:git pull origin 分支名
8.推送代码:git push origin 分支名
9.删除远程分支:git push origin :分支名
10.新建分支,并切换到新建的分支:git checkout -b 新分支名
11.将新建的分支推送到服务器:git push origin 新建的分支名
12.删除本地分支:git branch -D 分支名
13.合并某个分支到当前分支:git merge 需要合并到当前分支的分支名
14.强制回撤到某次提交的版本:git reset —hard 版本号的前6位(如:abe75e)
15.添加tag:git tag -a "标签名" -m"备注"
16.将添加的标签推送到远程服务器:git push —tag
17.进入到某哥tag:git checkout 标签名
18.强制回撤到某个标签:git reset —hard 标签名
19.删除本地tag:git tag -d 标签名
20.删除远程的tag:git push origin -–delete tag 标签名
21.删除git而不删除文件:find . -name ".git | xargs rm -Rf
22.查看git远程仓库地址:git remote -v
23.移除远程的git地址:git remote rm origin
24.将本地修改强制推送到服务器 git push -f -u origin master1.到本地仓库 cd
2.查看状态:git status
3.添加文件:git add .
4.提交 git commit -m"备注"
5.查看日志:git log
6.查看当前分支:git branch
7.拉取最新代码:git pull origin 分支名
8.推送代码:git push origin 分支名
9.删除远程分支:git push origin :分支名
10.新建分支,并切换到新建的分支:git checkout -b 新分支名
11.将新建的分支推送到服务器:git push origin 新建的分支名
12.删除本地分支:git branch -D 分支名
13.合并某个分支到当前分支:git merge 需要合并到当前分支的分支名
14.强制回撤到某次提交的版本:git reset —hard 版本号的前6位(如:abe75e)
15.添加tag:git tag -a "标签名" -m"备注"
16.将添加的标签推送到远程服务器:git push —tag
17.进入到某哥tag:git checkout 标签名
18.强制回撤到某个标签:git reset —hard 标签名
19.删除本地tag:git tag -d 标签名
20.删除远程的tag:git push origin -–delete tag 标签名
21.删除git而不删除文件:find . -name ".git | xargs rm -Rf
22.查看git远程仓库地址:git remote -v
23.移除远程的git地址:git remote rm origin
24.将本地修改强制推送到服务器 git push -f -u origin master
git branch --set-upstream-to=origin/remote_branch your_branch
比如从gitee切换到github:
➜ GitNote git:(master) ✗ git branch -alvv
* master 2a8f498 [gitee/master: 领先 61] Update _config.yml
remotes/gh/master 2a8f498 Update _config.yml
remotes/gitee/master 59a767d xx
➜ GitNote git:(master) ✗ git branch --set-upstream-to=gh/master master
分支 'master' 设置为跟踪来自 'gh' 的远程分支 'master'。
➜ GitNote git:(master) ✗ git branch -alvv
* master 2a8f498 [gh/master] Update _config.yml
remotes/gh/master 2a8f498 Update _config.yml
remotes/gitee/master 59a767d xx
git branch现在不输到的当然terminal了,而是以类似less的方式显示,一按q就没有了,有时你想对照着git branch的输出敲多个命令现在没法办到了。
解决办法:
git config --global pager.branch false
具体参考:https://www.codenong.com/48341920/
git config --global core.editor "vim"
git rev-parse --short HEAD
git config分 –system –global –local等。
–system是使用/etc/gitconfig文件的。 –global使用提~/.gitconfig文件 –local使用的是当前git仓的.git/config文件。
所以你可以进行一些本地化的配置。比如说git config –local user.email "xx",可以让你在不同的仓使用不同的身份提交代码。
git config --global user.name "zhangfuwen"
git config --global user.email "zhangfuwen@xxx.com"
git config --global core.editor vim
git config --global pager.branch false
git config --global alias.ll 'log --oneline'
overall picture:
type: Subject
body
footer
footer是元数据,用于指向issue id等。
feat
: A new feature fix
: A bug fix docs
: Changes to documentation style
: Formatting, missing semi colons, etc; no code change refactor
: Refactoring production code test
: Adding tests, refactoring test; no production code change chore
: Updating build tasks, package manager configs, etc; no production code change
feat: Summarize changes in around 50 characters or less
More detailed explanatory text, if necessary. Wrap it to about 72characters or so. In some contexts, the first line is treated as thesubject of the commit and the rest of the text as the body. Theblank line separating the summary from the body is critical (unlessyou omit the body entirely); various tools like log
, shortlog
and rebase
can get confused if you run the two together.
Explain the problem that this commit is solving. Focus on why youare making this change as opposed to how (the code explains that).Are there side effects or other unintuitive consequences of thischange? Here’s the place to explain them.
Further paragraphs come after blank lines.
Bullet points are okay, too
Typically a hyphen or asterisk is used for the bullet, precededby a single space, with blank lines in between, but conventionsvary here
If you use an issue tracker, put references to them at the bottom,like this:
Resolves: #123See also: #456, #789
git config --global alias.st 'status -sb'
git config --global alias.ll 'log --oneline'
git config --global alias.last 'log -1 HEAD --stat'
git config --global alias.se '!git rev-list --all | xargs git grep -F' # search commit
cd thirdparty
git submodule add https://xxx
git submodule init
git submodule update
git config --global url.ssh://git@github.com/.insteadOf https://github.com/
# or push use ssh
git config --global url.ssh://git@github.com/.pushInsteadOf https://github.com/