1

I am working on a project and I forked a repo from a team member who forked it from the original repo. He created a new branch with the same files and made changes in it.

However I cloned the original repo and worked on it and now I want to push the changes to my forked repo to the new branch he created. I went into the folder I made changes in, and I ran the following commands

git add .
git commit 
git push 

and I got

fatal: remote error: access denied ... /original-repo/project.git

I followed the instructions here: How can I push to my fork from a clone of the original repo?

but when I tried to run

git remote set-url origin https://github.com/xxx/project.git” 

I got “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.

Then I tried :

git remote add stash ssh://git@w.x.y.z:7999/xxx/project.git 
git push stash master

and I got

ssh: connect to host w.x.y.z port 7999: Connection timed out

although I set up my ssh key and was able to ssh successfully

Finally I thought about adding my fork, so I ran

git remote add fork https://github.com/xxx/project
git push fork master

and it prompted me for my username and password, then I got the following:

To https://github.com/xxx/project ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/xxx/project' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

EDITS:

I ran

git pull origin master

and got

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.


I ran

git pull github.com/xxx/project master

fatal: 'github.com/xxx/project' 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.

I am really not sure what to do, I really appreciate any help

Community
  • 1
  • 1
Sara A.
  • 11
  • 1
  • 6
  • It's saying you need to do a pull to merge existing changes. git pull origin master and then try your push again. – Dan Weber May 31 '16 at 17:39
  • Hello Dan, thank you for the attention. I updated the post – Sara A. May 31 '16 at 17:44
  • No problem, here is a good reference: https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes – Dan Weber May 31 '16 at 17:47
  • Try setting origin with git remote add origin https://github.com/sara94/project.git – Dan Weber May 31 '16 at 17:47
  • Either way, that is just for convenience. Try "git pull https://github.com/sara94/project master" and then "git push https://github.com/sara94/project master" – Dan Weber May 31 '16 at 17:48
  • I did that and it says "github.com/sara94/project" does not appear to be a git repository" although if I open "github.com/sara94/project" in the browser, it opens fine. I updated the post. – Sara A. May 31 '16 at 18:08
  • Okay, just checked your github account. You don't have any repositories. You need to create a new one and then that will give you an url to push to. Try creating one then I can help out further. – Dan Weber May 31 '16 at 18:26
  • Hi Dan, I figured out what went wrong. I forked the repo and cloned it in a folder where my old clone from the original repo resides. So Alot of files got messed up, I am redoing everything to be sure. Thank you for your patience! – Sara A. May 31 '16 at 22:00
  • Glad you figured it out. Good luck! – Dan Weber May 31 '16 at 22:14

2 Answers2

0

For this error:

ssh: connect to host w.x.y.z port 7999: Connection timed out

You need to indicate:

Hope it helps

0

I guess you can't pull to the fork. You will have to merge the fork with you main/master/whatever_branch_name.

There is this topic about GitHub ssh keys

Is it possible to have 2 (or more) GitHub accounts, 2 (or more) ssh key in one computer?