How to set up your git workflow

Scott
2 min readDec 6, 2019

Go to Github and get your shared (not your fork) repo.

Create a fork as well.

copy the url:

It doesn’t matter what branch you’re on, cloning takes all branches with it.

git clone <paste>

Go to your project.

YOU-MBP:~ YOU-Name$ cd YourProject/

Rename your origin

Scotts-MBP:akin scottlydon$ git remote rename <old-name> <new-name>

Like so:

Scotts-MBP:akin scottlydon$ git remote -v 
origin https://github.com/ElevatedUnderdogs/akin.git (fetch)
origin https://github.com/ElevatedUnderdogs/akin.git (push)
Scotts-MBP:akin scottlydon$ git remote rename origin upstreamScotts-MBP:akin scottlydon$ git remote -v
upstream https://github.com/ElevatedUnderdogs/akin.git (fetch)
upstream https://github.com/ElevatedUnderdogs/akin.git (push)

Now add your fork as your origin.

For example:

Scotts-MBP:akin scottlydon$ git remote add origin https://github.com/scott-lydon/akin-1.gitScotts-MBP:akin scottlydon$ git remote -v
origin https://github.com/scott-lydon/akin-1.git (fetch)
origin https://github.com/scott-lydon/akin-1.git (push)
upstream https://github.com/ElevatedUnderdogs/akin.git (fetch)
upstream https://github.com/ElevatedUnderdogs/akin.git (push)

Now lets create a develop branch if the main repo doesn’t have one. Type a unique name for your new branch, then select Create branch. Lets call it develop.

click “create branch”

Lets fetch the remote branch now:

git fetch upstream
git branch

If it shows

*master

Thats cool.

Now you are ready to create your local develop branch

git checkout -b develop upstream/develop

Make sure you spell your remote correctly or you might get some errors.

If you accidentally created a local branch, you can delete it by switching to master

git checkout master

, then running:

git branch -d <yourUnwantedBranch>

Now you can create a develop branch locally:

git checkout -b develop upstream/develop

When you want to push to this branch

git push origin branchName

--

--