'Pushing to a forked repo after clone from original

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://[email protected]: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



Solution 1:[1]

For this error:

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

You need to indicate:

Hope it helps

Solution 2:[2]

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?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Diego Meneses
Solution 2 Alberi De Paula