Setting up Git

I wrote this how-to for my bootcamp. Here it is!


Note – I’ve probably done this like 30 times in my life, and I still struggle with remembering the process. It’s a weird learning curve. But once you get it, you’ll still have to google to remember how to do it correctly.

Needs:

1) Make sure git is installed.

Open up your cmd/terminal:

Type “git –version”

—> If you get a version number, you are good to go. 

—> If you don’t:

WINDOWS USERS – I recommend getting a software package called chocolatey. Beside being tasty sounding, it’ll solve a LOT of headaches as a developer. 

Download Chocolately at: https://chocolatey.org/

Once that’s installed – open up a cmd.

Type “choco install git” <— (Follow these instructions: https://chocolatey.org/packages/git )

Then try the git –version again.


2) Make sure you have a github account.

Sign up here: http://github.com

Github is like… Dropbox/Google Drive for code. 


3) Create a test repo for the heck of it.

Click the Green NEW button. Screenshot: http://i.imgur.com/g2WI0T6.png

Repos are like… Project folders. 

You can set it to public or private. Here are my settings: http://i.imgur.com/A7ianfq.png

It’ll give you this screen, which means this repo is ready to be synced with your VSCode. http://i.imgur.com/IOTPe9W.png


4) Make sure you have a folder open in VS Code.

So you can either pull data FROM github or push data TO github. Let’s push data, because that’s easier for a beginner.

Create a new folder somewhere like git-test. (There’s a git-test folder in the zip file we downloaded. It’s empty btw.)

In VS Code, in the menu — File > Open Folder, and navigate to git-test.


5) Git commands.

We are going to connect the local folder on our computer to that Github cloud folder that we just made.

Load up a terminal. At the menu, View > Terminal. That will show this box. http://i.imgur.com/wElPLap.png

You’re going to run these commands one after another. 

Essentially, we’re following this, but slightly modified: http://i.imgur.com/zl6BINQ.png

Yours will be slightly different, based on your username.

Echo “# git-test” >> README.md <— this adds a readme.md file

git init <– this lets github know this folder is a git repo.

git add .  <— this adds ALL the files in the directory. 

git commit -m “first commit” <— this commits all the files.

By law, you MUST put the -m followed by a message in quotes. If you don’t, you literally get sucked into limbo. This is important for git. Always leave a note.

When I did this – apparently, I didn’t set up my user on this local VS Code. It gives you a warning and lets you know what you have to do.

Here’s my screenshot: http://i.imgur.com/F9puGiq.png

git remote add origin https://github.com/[YOURUSERNAME]/git-test.git <— this command connects your local folder to that github folder. 

Note: Change [YOURUSERNAME] to your username. 

git push -u origin master <— this pushes it to github.

It made me log in via the terminal.

USERNAME: If you forget your username, it’s the name on the top-left & top-right.(Example: RockyKev / git-test)

PASSWORD: Note, the cursor does not move when you type your password. It’s invisible. Just trust that you ARE typing a password.

Screenshot: http://i.imgur.com/mdU7ZJk.png


6) Check to see if your local ‘git-test’ folder is synced with the github ‘git-test’ repo by visiting the URL.

EXAMPLE: https://github.com/[YOURUSERNAME]/git-test/

It’ll look like this: 


7) You now know for sure that git is working with VS Code!

Leave a Comment