Search code examples
gitgithubgit-pushgit-clonegit-fork

Already cloned in Git when I should have forked. How do I redo this and push?


I've been using The Odin Project to teach myself programming. I thought I figured out Git but I am having a problem with pushing my latest assignment. When I tried to push it told me access denied because I originally cloned from another persons repo. I read that in this situation I'm supposed to fork instead of clone. For the course you're basically supposed to clone the repo and then fix everything and push it to your own. I don't want to lose anything I completed so I'm not sure what to do next. So far I've

-Cloned the repo
-Edited/fixed all the problems etc.
-Saved everything.
-git add -A
-git commit -m
-git push origin master

After the push I got the access denied .

Where do I go from here to fork and push all my files to my own repo without screwing everything up? I've never forked.

Also I'm curious can the Github Windows software be used to do everything you do from the command line?


Solution

  • First start by forking the original repository on GitHub. Then navigate to the fork on GitHub, copy the clone URL and add it as a remote to your repository. You can add the remote by executing git remote add <remote-name> <clone-url>. You can choose any name you want for the remote. As an example, I forked the git-scm repository. I could add it as a remote, named fork, by executing git remote add fork git@github.com:dennisschagt/git-scm.com.git. After adding the remote you can push the commits to your fork with git push fork master.

    About GitHub for Windows, you can do most regular tasks like creating commits, pushing, pulling, and merging but it has its limitations. For example, this task of adding a new remote is not possible in GitHub for Windows (as far as I know).