git学习实践笔记

2016-03-20

git使用和碰到的问题。

不定期使用记录

部分git命令碰到的问题

  1. git rm 将本地文件都删了,没有其他库…使用回退恢复。

    git log查看当初提交的id

    git reset --hard id号

    也可以: 直接从本地把文件checkout,用不着从远程服务器上pull下来(所有的历史版本你的本地都有的)。

    git checkout file

    若要同时恢复多个被删除的文件:

    git ls-files -d | xargs -i git checkout {}

  2. git commit -m “balabala”

  3. git pull报错

git pull报错:There is no tracking information for the current branch

There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details. git pull If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/ master

是因为本地分支和远程分支没有建立联系 (使用git branch -vv 可以查看本地分支和远程分支的关联关系) .根据命令行提示只需要执行以下命令即可:

1
2
3
4
git branch --set-upstream-to=origin/远程分支的名字  本地分支的名字
 即,解决方法:

git branch –set-upstream-to=origin/new new

本地环境执行:

1
2
3
4
5
6
7
执行: git branch
结果: * master

执行: git branch -r
结果: origin/master

执行: git branch --set-upstream-to=origin/master master 即可

Windows下git乱码问题

git乱码解决方案汇总

windows下出现中文路径自动转义了:

git乱码情景1: 在cygwin中,使用git add添加要提交的文件的时候,如果文件名是中文,会显示形如 274\232\350\256\256\346\200\273\347\273\223.png 的乱码。

解决方案: 在bash提示符下输入: git config --global core.quotepath false core.quotepath设为false的话,就不会对0x80以上的字符进行quote。中文显示正常。

tortoiseGit使用

  • git push操作: 右键tortoiseGit -> push -> 在Manage中管理远程的git URL路径 -> 确认后下拉框中进行选择 -> 选择OK -> 出来的框中输入用户名密码

  • git pull操作: 右键tortoiseGit -> pull 第一次git pull时,提示SSL证书问题,配置关闭SSL校验: git config –global http.sslVerify false This solution may open you to attacks like man-in-the-middle attacks git的时候出现问题SSL Error: unable to get local issuer certificate

会不定期在原笔记记录的基础上添加修改部分内容,更早之前的一些整理比较初级,也没有碰到实际使用


  • 本文作者: xiaodongQ
  • 本文链接: /2016/03/20/git-note/
  • 版权声明: 本文可以自由拷贝,转载,请注明出处,谢谢! 🤝

Comments