简体   繁体   中英

Not able to pull or push in the github repository

I am new in the git world. I am not able to understand why I am not able to pull or push things in the github repository. This is the link for the clone 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

fatal: 'origin' 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...

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. 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. Based on what you're describing you don't need to do the git init (that's for creating a brand new repository).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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