程序员的资源宝库

网站首页 > gitee 正文

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

sanyeah 2024-04-13 16:09:45 gitee 3 ℃ 0 评论

 
  • 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

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表