简体   繁体   English

无法拉入或推入github存储库

[英]Not able to pull or push in the github repository

I am new in the git world. 我是git世界的新手。 I am not able to understand why I am not able to pull or push things in the github repository. 我不明白为什么我不能在github仓库中拉东西。 This is the link for the clone https://github.com/Mohsin05/developer.git 这是克隆的链接https://github.com/Mohsin05/developer.git

I am using these commands.... 我正在使用这些命令。

$ git init
$ git config --global user.name "mohsin05"
$ git config --global user.email "mohsinyounas@gmail.com"
$ git clone https://github.com/Mohsin05/developer.git
$ git remote -v
$ git add .
$ git commit -am"First"
$ git push origin master

My folder on the computer is updated with respect to the github repository but when i make any change in the file and try to push it gives this error 我在计算机上的文件夹相对于github存储库进行了更新,但是当我在文件中进行任何更改并尝试推送时,都会出现此错误

fatal: 'origin' does not appear to be a git repository 致命的:'origin'似乎不是git存储库

fatal: Could not read from remote repository. 致命:无法从远程存储库读取。

Please make sure you have the correct access rights and the repository exists... 请确保您具有正确的访问权限,并且存储库存在...

Moreover I can not create any new branch and it does not sync. 此外,我无法创建任何新分支,并且它不会同步。

The problem is that you're not creating a commit on your clone of the github repository, you're creating a commit on a repo in the parent directory of the cloned github repo. 问题是您没有在github存储库的克隆上创建提交,而是在克隆的github存储库的父目录中的存储库上创建了提交。 This is because your script is actually creating two git repos on your local machine: One in the initial directory ( git init ) and then one in a child directory ( git clone )--git clone will checkout the code from github and put it in a child directory from where it's called. 这是因为您的脚本实际上是在本地计算机上创建两个git存储库:一个在初始目录( git init )中,然后在一个子目录( git clone )中-git clone将从github检出代码并将其放入子目录的调用位置。 Based on what you're describing you don't need to do the git init (that's for creating a brand new repository). 根据您所描述的内容,您无需执行git init (用于创建全新的存储库)。

What you really want is something along the lines of: 您真正想要的是以下方面的东西:

git clone https://github.com/Mohsin05/developer.git
cd developer
touch First
git add First
git commit -am"First"
git push origin master

This clones your github repo, switches ( cd s) into the repo directory, creates a file named First , adds it to the repo, commits it with the comment First , and the pushes it up to github. 这将克隆您的github存储库,将( cd )切换到repo目录,创建一个名为First的文件,将其添加到该存储库,使用注释First提交它,并将其推送到github。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM