Git Tutorial for Beginners

index1@2x

       

         Working Directory

Stores all the project files.

         Staging Area

Also called the index. Essentially a single ledger or manifest that acts like a set of instructions for all proposed changes to the repository.

         Repository

Holds all the committed files.

 

Setup

Create a Github Repository

https://github.com

Create an account or sign in

Create a repo and upload your project files

Install Git

https://git-scm.com/

Launch Git

Let Git know who you are

git config --global user.name "Your_User_Name_Here"
git config --global user.email "Your_Email@Domain.com"

Change Directory to the Desktop

cd desktop

Make a new folder for your working directory

mkdir 'github tutorial'

Go into the folder you just made

cd 'github tutorial'

Clone your remote repo

git clone https://github.com/{yourname}/{repository}

Create readme text file and edit in the vim editor

vim readme


Insert the file. Add some text. Save

i or Insert key         #Insert (enter document for editing)

Arrow keys              #Navigate document

ctrl+[                  #Escape document back into console

:q                      #Quit WITHOUT Saving

:x                      #Save and Quit

Now you can see all the untracked (new files) and unstaged files.

git status

Add all files to the staging area. Alternatively, you could specify the readme file in place of the period since it’s the only untracked file.

git add .

Always commit with a message in quotes

git commit -m "fixed transaction rounding errors"

The readme file is ready to be merged with the online github repo. “-u” saves branch configuration (origin master) and allows push and pull to work as expected. In the future Git now knows from where to push and pull.

 

git push -u

On branch master
Your branch is up-to-date with ‘origin/master’.
nothing to commit, working directory clean

git status

Check your github repo and you should see the readme file. Not too shabby.


Command Line Reference:

https://ss64.com/bash/

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: