git常用命令以及回退分支并强推至远程

 
复制代码
  • git安全凭证存储

  Git-Credential-Manager-for-Windows

  • 设置git push和pull的默认远程分支

  git branch --set-upstream-to=origin/master master
  • 删除本地或者远程分支

  本地:git branch -d [branch name]   远程:git push origin --delete branchName  或者 git push origin :branchName
  • 创建+切换分支

  git checkout -b [branch name]
  • 推送本地新分支到远程仓库

   git push origin [branch name]:[branch name] 或者 git push origin [branch name]

  • 查看远程分支 以及 查看所有分支 

   git branch -r git branch -a

  • 本地分支和远程分支建立映射关系 

  git branch -u origin/分支名,或者git branch --set-upstream-to origin/分支名  查看映射关系:git branch -vv
  • git回退版本代码 强推至远程仓库

  git reset HEAD^   git reset <commit>  git reset HEAD~5  回退
  git reset --hard HEAD^ 回退已经提交的版本加上 --hard
  git push -f origin master
  如果是master有保护机制 还需要设置gitlab 选中项目,settings ==> repository ==> Protected Branches ==> Unprotect
  推送完再设置保护上
  • 查看 Git 中当前的版本信息

  git log    按 q 退出
  • git合并

  git checkout master
  git pull origin master
  git merge dev //如果有冲突,手动解决冲突就行。
  git status
  • 修改远程库配置

  git remote rm origin 
  git remote add origin [url]
  git remote -v
  git remote show origin //查看有没有更新
  • 查看本地公钥

  cat ~/.ssh/id_rsa.pub //
  • 查看当前账号和邮箱 配置信息

  git config --global --list
  git config user.name   git config user.email
  git config --global user.name "xxx"  // 如果有误的话可以切换用户名和邮箱:
  git config --global user.email "xxx"
  • 创建仓库

  mkdir renren-fast
  cd renren-fast
  git init 
  touch README.md
  git add README.md
  git commit -m "first commit"
  git remote add origin https://gitee.com/jane668/renren-fast.git
  git push -u origin "master"
  • 配置 socks5 代理

    git config --global http.proxy socks5 127.0.0.1:7890
    git config --global https.proxy socks5 127.0.0.1:7890


  • 配置 http 代理

    git config --global http.proxy 127.0.0.1:7890
    git config --global https.proxy 127.0.0.1:7890

  • 查看/取消 代理命令

    git config --global --get http.proxy

    git config --global --get https.proxy

    git config --global --unset http.proxy

    git config --global --unset https.proxy

复制代码

 

git config --global --lis
posted @   无泪的遗憾、愿我能  阅读(671)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
浏览器标题切换
浏览器标题切换end
点击右上角即可分享
微信分享提示