git常见问题总结

2023-11-20

1、.xxx.com port 22: Connection refused

ssh: connect to host xx.xxx.com port 22: Connection refused fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists

  1. 首先已经在gitlab上有了账户。
  1. 终端 cd ~/.ssh , 检查是否显示有id_rsa.pub 和 id_dsa.pub是否已经存在 。
  1. 如果不存在,则创建,终端ssh-keygen -t rsa -C “xxx.xxx@xxx.com”,这里是你的邮箱地址,一路回车就可以了。
  1. 创建后,open . 直接打开当前目录,看到 id_rsa.pub 和 id_dsa.pub 已创建成功。
  1. 用记事本打开id_rsa.pub文件,并且复制全部内容。
  1. 在你的gitlab账户,打开SSH key标签。 然后选择Add SSH key按钮,将刚刚复制的内容粘贴进去即可,然后点击add key。
  1. 如果克隆还是报错,需要配置config,cd ~/.ssh 回车, touch config 回车,open . 打开看一下config文件已创建成功。
  1. 用记事本打开config文件,里面添加对应的配置
    Host xxx.xxx.com
    Port xxx

这个配置的地址和和端口问公司的运维人员。

2、xcrun: error: invalid active developer path

我是在更新电脑系统后,使用Xcode,发现不能使用,提示需要install一些组件,于是我install了。之后使用终端git clone 一个仓库时候报这个错误。

xxx$ git clone git@gitlab.vhall.com:xxx/xxx_ios.git
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

在这个路径下,缺少xcrun。xcrun是做什么的?

which git ,看了下git是已安装了的;

brew install git , 更新git,提示

Error: The following formula:
git
cannot be installed as a binary package and must be built from source.
Install the Command Line Tools:
xcode-select --install
Error: Git must be installed and in your PATH!
Error: The following formula:
git
cannot be installed as a binary package and must be built from source.
Install the Command Line Tools:
xcode-select --install

执行 xcode-select --install 更新 Command Line Tools 。

3、终端使用git发现不能用这么办

有可能没安装,先安装git,Mac系统安装Xcode的话自带git安装。

如果已安装Xoce发现git还是不好用,更新Command Line Tools,命令xcode-select --install

4、<<<<<<< HEAD

<<<<<<< HEAD
    config.isPrintLog = YES;
=======
    config.videoBitRate = self.videoBitRate;
    config.captureDevicePosition = AVCaptureDevicePositionBack;
>>>>>>> dev

merge时导致冲突,=和dev之间是自己的代码,HEAD和=之间是冲突代码。

解决冲突时,一般是保留最新的代码,根据实际情况确定。

5、error:src refspec master does not match any

git init 
git touch READMEgit 
git add README 
git commit -m 'add readme'
git push -u origin master

6、Updates were rejected because the tip of your current branch is behind

error: failed to push some refs to 'git@gitlab.xxx.com:xxx/xxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details

push前先pull

$ git pull origin master

然后push

$ git push -u origin master

就ok了。

如果想要本地直接覆盖远程,用强制push的方法,但是注意这种操作是不可恢复的,使用需注意。

$ git push -u origin master -f

7、push fatal: 'master' does not appear to be a git repository

Pushing to master
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

git remote add origin git@github.com:vhall/xxx.git
fatal: remote origin already exists.

$ git remote -v
origin master (fetch)
origin master (push)

git remote set-url origin git@github.com:xxx.git

$ git remote -v
origin git@github.com:xxx.git (fetch)
origin git@github.com:xxx.git (push)

ok可以push了

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

git常见问题总结 的相关文章

随机推荐