美文网首页
git 常用命令

git 常用命令

作者: 愿你如夏日清凉的风 | 来源:发表于2017-05-03 11:41 被阅读16次

当你更改了文件后,发现分支是错误的,本来应在A上修改,结果在B上修改了。那么怎么办呢?

不着急,有办法~

1)如果你在分支B上的文件还没有commit

  • 先 git stash,把没有commit的更改文件暂存在一个地方,这个地方git知道,你是看不到的。
  • 切换到正确的分支A。
  • 使用git stash pop 命令,把暂存的文件找回来。
    这就是 [ git stash ] 和 [ git stash pop ] 的秘密。
    总结而言:先保存好修改的版本,然后切换分支,切换回来再去把修改的拉回来。

当我们用https clone项目到本地的时候,git push命令每次都需要输入密码,下面的方法可以很快的解决这个麻烦。

git config credential.helper store
git pull 输入密码

file ~/.git-credentials
cat ~/.git-credentials
密码其实是明文存在途中的 ~/.git-credentials 这个文件里的,你可以打开看呢。

相关文章

网友评论

      本文标题:git 常用命令

      本文链接:https://www.haomeiwen.com/subject/fyrhtxtx.html