批量删除 git 分支
1
| git branch -a | grep -e "fix/" | xargs git branch -D
|
批量添加匹配文件到暂存区
1
| git status -s -uall | grep .vue | awk '{print $2}' | xargs git add
|
按最后提交日期排序所有远程分支
1
| git branch -rv --sort=-committerdate
|
更多:How can I get a list of Git branches, ordered by most recent commit?
更好的 git log
1
| 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"
|
列出另外一个分支没有的提交
1
| git cherry -v branch-A branch-B
|
clone 特定分支
1
| git clone -b develop git@github.com:user/myproject.git
|
递归移动文件夹
列出特定分支的记录
查看特定文件的 git 记录
修改 git 提交为任何人
1
| git -c user.name="NEW NAME" -c user.email="new_email@gmail.com" commit --amend --date="Tue Nov 20 03:00 2018 +0100" --author="NEW NAME <new_email@gmail.com>"
|
查看当前所有子目录的 git 状态
1
| find . -maxdepth 1 -mindepth 1 -type d -exec sh -c '(echo {} && cd {} && git status -s && echo)' \\;
|
创建 git 归档时忽略某些目录
1
| tar cvfz app.tar.gz --exclude ".git/*" --exclude ".git" app/
|
列出未发布的 commit
在所有 commit 中寻找代码
1
| git rev-list --all | xargs git grep
|
找到一个文件是何时被删掉的
1
| git log --diff-filter=D -- path/to/file
|
删除远程分支
让 git 可以递归调用
1
| git config --global alias.git '!git'
|
revert cherry-pick
1
| git rebase -p --onto SHA^ SHA
|
永久删除文件
1
| git filter-branch --tree-filter 'rm -rf my_folder/my_file' HEAD
|
永久链接
1
| permalink = "!f() { echo "https://$(git config --get remote.origin.url | grep --color=never -o -E 'github.com[:/][^\\.]+' | sed s/\\:/\\\\//)/commit/$(git rev-parse @{u})"; }; open $(f)"
|
仅忽略本地副本的文件更改
1 2 3
| git update-index --assume-unchanged <file>
git update-index --no-assume-unchanged <file>
|
忽略已跟踪的文件
获取当前分支名称
1
| git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
|
查看某个版本的目录树
1 2 3
| git show HEAD~5:hello.txt
git show awesome-feature:app/models
|
🥳 加载 Disqus 评论