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
- 首先已经在gitlab上有了账户。
- 终端 cd ~/.ssh , 检查是否显示有id_rsa.pub 和 id_dsa.pub是否已经存在 。
- 如果不存在,则创建,终端ssh-keygen -t rsa -C “xxx.xxx@xxx.com”,这里是你的邮箱地址,一路回车就可以了。
- 创建后,open . 直接打开当前目录,看到 id_rsa.pub 和 id_dsa.pub 已创建成功。
- 用记事本打开id_rsa.pub文件,并且复制全部内容。
- 在你的gitlab账户,打开SSH key标签。 然后选择Add SSH key按钮,将刚刚复制的内容粘贴进去即可,然后点击add key。
- 如果克隆还是报错,需要配置config,cd ~/.ssh 回车, touch config 回车,open . 打开看一下config文件已创建成功。
- 用记事本打开config文件,里面添加对应的配置
Host xxx.xxx.com
Port xxx
这个配置的地址和和端口问公司的运维人员。
我是在更新电脑系统后,使用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 。
有可能没安装,先安装git,Mac系统安装Xcode的话自带git安装。
如果已安装Xoce发现git还是不好用,更新Command Line Tools,命令xcode-select --install
<<<<<<< HEAD
config.isPrintLog = YES;
=======
config.videoBitRate = self.videoBitRate;
config.captureDevicePosition = AVCaptureDevicePositionBack;
>>>>>>> dev
merge时导致冲突,=和dev之间是自己的代码,HEAD和=之间是冲突代码。
解决冲突时,一般是保留最新的代码,根据实际情况确定。
git init
git touch READMEgit
git add README
git commit -m 'add readme'
git push -u origin master
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
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了