git 修改branch
git branch -m server
git 修改 message
# git config --global core.editor /usr/bin/vim
git commit --amend
git 撤销commit
git reset --soft HEAD~2 # 这样可以保证add 的还在,就是修改的代码还在
git lfs
git lfs install
git lfs track (xxfile)
git add .gitattributes
git add xxfile
git commit -m "xx"
git push
以前的code
git rebase
删除或合并 commit
通过 git log 查到commit id
如 git log --before='2020-2-20"
然后 git rebase -i id
这个就修改, 把 pick 改成
d: drop
s/f: 合并消息,不合并消息
然后保存。
之后 git push -f。 【我就是这里居然用了 git pull 导致 git log 混乱了】
git checkout --orphan
把之前的所有的commit清除掉,从本次开始记录
当然我不知道如何把某次commit 之前的清掉保持本次和本次之后的commit。
git checkout --orphan chj
git add -A
git commit -am "commit message"
git branch -D master
git branch -m master
git push -f origin master
清除文件
git rev-list --objects --all > 3.txt
# git log --before="2020-02-20"
# |\.~vsd\.pdf|paper/Tmp|\.eps
for a in `egrep '\.eps' 3.txt |awk '{print $2}' `
do
echo $a
#git log --pretty=oneline --branches -- ${a}
git filter-branch --index-filter \
"git rm --cached -r --ignore-unmatch ${a}" \
-f --prune-empty --tag-name-filter cat -- --all
git push github master --force #--tags
git reflog expire --expire=now --all
rm -Rf .git/refs/original
rm -Rf .git/logs/
#git gc
#git prune
git gc --prune=now
git gc --aggressive --prune=now
# exit
done
该脚本后面的几个命令可以用来压缩.git文件。