git 技巧

2019-11-06  本文已影响0人  pipu

当你写的代码不在你想要的开发分支的时候,使用git stash 记录中当前的修改,切换到开发的分支 使用 git stash pop 命令将修改拿出来。

git从某次提交拉分支

git checkout -b branchname <commitId>

查看某个commit的改动

查看所有的log

git log --oneline --graph --decorate --all
git log --pretty=oneline --graph --decorate --all

查看某个文件的改动

git log -p filename

查看某个commit 属于某个分支

添加文件和commit在一个命令中使用别名属性

git config --global alias.ac '!git add -A && git commit -m'
...
[alias]
    ac = !git add -A && git commit -m
...

使用特定分支上的文件替换当前分支上的文件

git checkout sourc_branch <paths>...
上一篇 下一篇

猜你喜欢

热点阅读