git常见问题

git常见问题

1.

  • 1.git push 中remote: Permission to xxxxx.git denied to xxx. fatal: unable to acce
由于电脑使用git bash 配过SSH, 系统已经将指向github.com的用户设置之前用户,系统默认读取保存在本地的之前用户
  • 解决方式:
修改.git/config中url:
将
[remote "origin"]
url = https://github.com/git的用户名/项目名称
的url改为
url = https://git的用户名@github.com/git的用户名/项目名称
然后
git push -u origin master

2:

  • git切换分支并新建
git checkout -b 新分支名字
  • 只是切换分支
git checkout 分支名字

3:

  • git配置 .gitignore
touch .gitignore
  • 忽略文件
*.html
*.png
public/
  • 最后需要强调的一点是,如果你不慎在创建.gitignore文件之前就push了项目,那么即使你在.gitignore文件中写入新的过滤规则,这些规则也不会起作用,Git仍然会对所有文件进行版本管理。

4:

  • git忽略logs文件下所有日志文件,但想保留logs文件夹
logs文件夹下新建.gitignore,输入如下内容
# ignore all except .gitignore file
*
! .gitignore

5:

  • git push报错 fatal: HttpRequestException encountered.▒▒▒▒▒▒▒▒ʱ▒▒▒▒ libpng warning: iCCP: cHRM chunk does not match sRGB Everything up-to-date

    下载GCMV-1.20.0.exe

原文地址:https://www.cnblogs.com/xujunkai/p/13823977.html