Git 推送问题和拉取问题



我创建了一个裸存储库(/Volumes/500gb/myproject.git)。

我已将裸存储库添加到我的工作目录中/Volumes/500gb/test1.

我创建了如下分支:

# git branch
master
test1
* test2

我已经在分支test2中创建了一个文件并提交。

  1. 当我尝试推送到分支test2时,出现以下错误:

    # git push origin master
    To /Volumes/500gb/myproject.git
    ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to '/Volumes/500gb/myproject.git'
    hint: Updates were rejected because a pushed branch tip is behind its remote
    hint: counterpart. Check out this branch and merge the remote changes
    hint: (e.g. 'git pull') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    
  2. 当我尝试从master中提取时,我收到以下错误。但是我可以合并mastertest2分支.

    # git pull 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 pull 的语法是git pull <repository> <refspec>

在您的情况下,当您调用git pull master时,git 认为您要从名为master的存储库中提取当前分支状态。

因此,如果您使用的是 master,只需键入git pull,或者更准确地说git pull origin master

来源: https://git-scm.com/docs/git-pull

一旦您可以拉取和更新本地存储库状态,您的第一个问题应该更容易解决。

最新更新