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
git reset --hard HEAD # Revert (rolling back) to your current head point
# git revert using by IntellIJ IDEA
git -c core.quotepath=false rm --cached -f -- FILE_PATH
git -c core.quotepath=false checkout HEAD -- FILE_PATH
git config --global core.autocrlf input/true/false
git config --global core.safecrlf warn/true/false
-
-
Save wuliupo/388ec155d2032414500848d8d51a6007 to your computer and use it in GitHub Desktop.
rename git branch locally and remotely
Author
wuliupo
commented
Dec 27, 2016
-
remove cached files
git rm --cached submod-names
-
remove config files
manual remove submodule lines in.gitmodules
-
remove file on disk (maybe link)
rm -rf submod-names # linux file or dir
DEL /F /A /Q # windows file
RD /S /Q # windows dir
git submodule add ~/git/libs/lib1.git libs/lib1
git submodule add https://github.com/wuliupo/jstutorial.git jstutorial
如果还没有 push,合并提交到上一次
git -c core.quotepath=false commit --amend --only -F git-commit-msg.txt -- the_new_commit_file
添加新文件
git -c core.quotepath=false add --ignore-errors -- the_new_commit_file
删除添加的文件
git -c core.quotepath=false rm --ignore-unmatch --cached -- the_new_commit_file
提交之前的最后一次改动是 the_number_1234567
本地提交一次改动
git commit -m "new message"
取消刚刚提交的改动
git -c core.quotepath=false reset --soft the_number_1234567
从远程 master 拉分支
git -c core.quotepath=false checkout -b 新分支名字 origin/master --
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment