Usage
1
| git config --global core.quotepath false
|
1
2
| git fetch
git checkout -b local-branchname origin/remote_branchname
|
1
| git push origin --delete branchName
|
1
| git log --pretty=oneline 文件名
|
1
| git diff HEAD -- filename
|
- 丢弃工作区的修改 回到最近一次 git commit 或 git add 时的状态
1
| git reset --hard commit_id
|
- 修改 commit 记录(push 要 force)
1
| git remote add origin git@hostname:aaa.git
|
1
| git remote set-url origin <URL>
|
1
| git push -u origin master
|
1
2
3
| git diff topic master # 将两个分支上最新的提交做 diff,相当于 diff 了两个 commit
git diff topic..master # 同上
git diff topic...master # 输出自 topic 与 master 分别开发以来,master 分支上的 change
|
1
| git log --graph --pretty=oneline --abbrev-commit
|
- 合并分支时,加上–no-ff 参数就可以用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而 fast forward 合并就看不出来曾经做过合并。
1
2
| git tag tag_name
git tag tag_name commit_id
|
1
| git tag -s tag_name -m "signed version 0.2 released" commit_id
|
1
| git push origin tag_name
|
1
2
| git tag -a v1.4 -m 'my version 1.4'
git show v1.4
|
1
2
| git tag -d v0.9
git push origin :refs/tags/v0.9
|
1
2
3
4
5
| git log
git reset --hard 7b78c88
git push -f
git merge go
git push
|
1
2
3
| git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
|
1
2
3
| java -jar bfg-1.12.12.jar --strip-blobs-bigger-than 100M [仓库目录]
java -jar bfg-1.12.12.jar --delete-files id\_{dsa,rsa} [仓库目录]
git gc --prune=now --aggressive
|
1
| git pull origin master --allow-unrelated-histories
|
- 删除文件
使用 git filter-branch 替换历史,然后 –force push。
比如把写有密码的 Rakefile 不小心 push 到 Github 上的话,做以下操作即可。
1
2
| $ git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch Rakefile' --prune-empty --tag-name-filter cat -- --all
$ git push origin master --force
|
1
2
3
4
5
6
| # add
git submodule add https://github.com/saturn-xiv/hugo-bootstrap.git themes/bootstrap
upgrade source code
git submodule update --remote --merge
cd themes/bootstrap
git push --recurse-submodules=check
|