For many tutorials I will start by cloning a repo, doing work locally and then wanting to push it up onto my github. That is generally pretty simple, but the push will try to push changes to the repo I just cloned. I’m not at a point where I want to be submitting changes to the tutorial assets – I’m just doing the tutorial! The critical thing is that I need to change the remote origin to my own new github repo.
Anyways, here are the steps
- cd into the future directory of the repo on my local machine
- cd /path/to/my/dir
- go to the repo on github and copy the clone link. screengrab below.
- clone the repo
- git clone https://github.com/pathToTheirRepo.git
- cd into the new directory you just made
- cd /repoName
- go to github, create a new repo, and grab the clone link (see above) from the new repo.
- set the remote origin url (this is where you will be pushing to)
- git remote add origin https://username@stash/scm/PROJECT/repo.git
- check the remote origin (optional). This should be the path to your repo.
- git remote -v
- push the project to your repo
- git push
And you’re done!
The alternative workflow to this is to fork it on github and then clone it from there. That has some advantages, but the main disadvantage is that I will sometimes start working on something and then decide to move on without completing it. If I clone it locally and then decide to move on before pushing I can just delete the directory. Otherwise I need to delete the directory AND delete the repo.