Skip to content

Git相关操作 ​

更换仓库地址 ​

shell
git remote -v
git remote rm origin
git remote add origin xxx

or

shell
git remote set-url origin xxx

git拉取所有分支 ​

shell
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all

推送本地所有分支 ​

shell
git push --all origin -u

切换(并创建)分支 ​

shell
git checkout [-b] branch

放弃更改相关 ​

  • 未提交到暂存区
shell
git checkout .
  • 已提交暂存区
shell
git reset HEAD .
  • 已执行commit操作
shell
git reset --hard HEAD^

命令行储存密码 ​

bash
git config credential.helper store

Made with ❤️ by Lion