“Git”的版本间的差异

来自qingwei personal wiki
跳转至: 导航搜索
git pull/fetch: unable to update local ref
回滚到上一个commit
 
(未显示同一用户的6个中间版本)
第1行: 第1行:
 +
== SSH key生成 ==
 +
=== windows ===
 +
<source lang="shell">
 +
#生成ssh key的命令
 +
qingwyan@QINGWYAN-FTCEW MINGW64 ~/Desktop/git
 +
$ ssh-keygen -t rsa -C "qingwyan@cisco.com"
 +
 +
# 进入到生成的ssh key目录
 +
qingwyan@QINGWYAN-FTCEW MINGW64 ~/Desktop/git
 +
$ cd /c/Users/qingwyan/.ssh
 +
 +
# copy到剪切板
 +
qingwyan@QINGWYAN-FTCEW MINGW64 ~/.ssh
 +
$ clip < id_rsa.pub
 +
</source>
 +
 
== 常见错误 ==
 
== 常见错误 ==
 
=== git pull/fetch: unable to update local ref ===
 
=== git pull/fetch: unable to update local ref ===
第26行: 第42行:
 
<source lang="shell">
 
<source lang="shell">
 
git remote prune origin
 
git remote prune origin
 +
</source>
 +
== 常用命令 ==
 +
=== 当前分支commit数量 ===
 +
<source lang="shell">
 +
# 获取当前分支的 commit 数量
 +
git rev-list HEAD --count
 +
 +
# 比上面的少点 ---上面的会有重复的,少了些重复的, >< 我也不知道。。。
 +
git rev-list HEAD --count --first-parent
 +
</source>
 +
=== 回滚到上一个commit ===
 +
<source lang="shell">
 +
git reset --hard <commit_id>
 +
git push origin HEAD --force
 +
</source>
 +
 +
=== git diff忽略^M ===
 +
<source lang="shell">
 +
git config --global core.whitespace cr-at-eol
 
</source>
 
</source>

2018年11月16日 (五) 09:24的最新版本

SSH key生成

windows

#生成ssh key的命令
qingwyan@QINGWYAN-FTCEW MINGW64 ~/Desktop/git
$ ssh-keygen -t rsa -C "qingwyan@cisco.com"

# 进入到生成的ssh key目录
qingwyan@QINGWYAN-FTCEW MINGW64 ~/Desktop/git
$ cd /c/Users/qingwyan/.ssh

# copy到剪切板
qingwyan@QINGWYAN-FTCEW MINGW64 ~/.ssh
$ clip < id_rsa.pub

常见错误

git pull/fetch: unable to update local ref

  • 现象
[qingwyan@crdc-sdn-ucs2 rpd-service-manager]$ git fetch

error: there are still refs under 'refs/remotes/origin/bugfix/haofan'
From ssh://bitbucket-eng-sjc1.cisco.com:7999/cmtsorch/rpd-service-manager
 ! [new branch]      bugfix/haofan -> origin/bugfix/haofan  (unable to update local ref)
  • 解决方案:删除文件
rm -rf .git/refs/remotes/origin/bugfix/haofan
  • 新的问题
[qingwyan@crdc-sdn-ucs2 rpd-service-manager]$ git fetch

error: 'refs/remotes/origin/bugfix/haofan/device-key' exists; cannot create 'refs/remotes/origin/bugfix/haofan'
From ssh://bitbucket-eng-sjc1.cisco.com:7999/cmtsorch/rpd-service-manager
 ! [new branch]      bugfix/haofan -> origin/bugfix/haofan  (unable to update local ref)
error: some local refs could not be updated; try running
 'git remote prune origin' to remove any old, conflicting branches
  • 按提示删除
git remote prune origin

常用命令

当前分支commit数量

# 获取当前分支的 commit 数量
git rev-list HEAD --count

# 比上面的少点 ---上面的会有重复的,少了些重复的, >< 我也不知道。。。
git rev-list HEAD --count --first-parent

回滚到上一个commit

git reset --hard <commit_id>
git push origin HEAD --force

git diff忽略^M

git config --global core.whitespace cr-at-eol