Git 常用操作命令

188 阅读1分钟

Git

  • 删除本地分支
git branch -d dev
  • 删除远端分支
git push origin :dev
  • 加入新文件到stage
git add *
  • 从stage中删除
git rm -r --cached *
  • 提交
git commit -m '备注信息'
  • 推送至远端
git push
  • 从远端拉取
git pull
  • 查看分支
git branch
  • 创建新分支
git branch 分支名
  • 切换分支到dev
git checkout dev
  • 推送新建的分支到远端
git push origin dev:dev
  • 删除分支
git branch -d dev
  • 删除后推送到远端
git push origin :dev
  • 查看远程仓库地址
git remote -v
  • 修改远程仓库地址
git remote set-url origin https://gitee.com/***/***.git
  • 查看git当前账户
git config user.name
git config user.email

git config --global user.name "Your_username"
git config --global user.email "Your_email"
  • 让git每次pull都提示密码
git config --global credential.helper cache