LivingProgram / git-tutorial

CS Roundtable, teaching basics of github, gitbash and the amazing vim editor
0 stars 0 forks source link

Tutorials #1

Open LivingProgram opened 8 years ago

LivingProgram commented 8 years ago

Getting Started With Git Bash

Setting up 2 properties

Assuming you have already downloaded git bash and set up jekyll here

Let's go!

  1. Search your computer for git bash image then open image
  2. Type cd in the command line (to put you in the home directory) image

Setting up Username

  1. Type git config --global user.name "YourUsername" while substituting YourUsername with your username

image

Setting up User Email

  1. Type git config --global user.email YourEmail@example.com while substituting YourEmail with your email

image

You have now setup Git Bash! :+1:

LivingProgram commented 8 years ago

Cloning the Repository on Bash

Benefits include:

  1. Easily copying many files from one place to another
  2. Working offline! :smiley:

Let's go!

  1. Search your computer for git bash image then open image
  2. Type cd in the command line (to put you in the home directory) image
  3. Type git clone https://github.com/bigdata-mindstorms/jekyll-playground.git image
  4. You should have the repo cloned to your computer, but to verify type cd jekyll-playground/ image You should end up with something like the above, and you will now have changed from your home directory, to the jekyll-playground!

Congrats, you just cloned a local repo! :+1: :smile:

LivingProgram commented 8 years ago

Navigating Git Bash

In order to learn how to navigate, add files/folders, and remove files/folders start reading here and then go here

Try navigating to one of your own folders using what you learn above (cd command), and try adding folders or files within your folder to practice.

Example: image

LivingProgram commented 8 years ago

Cheat Sheet (Navigating Git Bash)

For full explanations with screen shots, look here

  • Ignore $
  • name of destination folder = DestinationFolder
  • name of file = FileName
  • name of folder = FolderName

Clear bash window: $ clear See list of folders/files within directory: $ ls Navigate $ cd DestinationFolder Go up a folder: $ cd .. Create folder: $ mkdir FolderName Remove folder: $ rmdir FolderName Create file: $ touch FileName Create file: $ echo New line of text in the new file >> FileName Add line of text to file: $ echo Add this line of text to end of file >> FileName Replace text in file: $ echo Replace everything in file with this line > FileName Remove file: $ rm FileName Remove folder and all contents: $ rm -rf FolderName Remove folder and all contents, also output what has been done: $ rm -rfv FolderName

LivingProgram commented 8 years ago

Editing Files With Vim

Using the built in editor vim to edit git files

Understanding Vim

A text editor that is extremely efficient for you to edit files

  1. Open git bash
  2. Type: $ vimtutor
  3. Zoom in on the screen, until lesson fills the screen
  4. Follow instructions to learn Vim!

Editing Files

  1. Open up git bash
  2. Navigate into the directory containing the file you want to edit
  3. Type (name your file = FileName): $ vi FileName
  4. Now you are in a vim text editing environment (remember to save when exiting)
LivingProgram commented 8 years ago

Basic Vim Cheat Sheet

Cheat sheet for the controls in the Vim text editor (for full array of commands look at the vimtutor

Move up: j Move down: k Move left: h Move right: l Exit editor (without saving): :q! Exit editor (with saving): :wq Delete character: x Insert text: i Append text (to end of line): a Highlight text: v Copy text: y Paste text: p Delete word (insert number, x, before w, to delete x amount of words): dw Delete line (insert number, x, before w, to delete x amount of words): dd Delete to end of line (insert number, x, before w, to delete x amount of words): d$ Delete to end of word (insert number, x, before w, to delete x amount of words): de Undo last command: u Undo whole line U Undo the undo (pressing CTRL key, then R): CTRL-r Find matching ),], or }: % Search for phrase (your phrase = Phrase): /Phrase

LivingProgram commented 8 years ago

Learn markdown here