Git/Github and the Terminal







Setup Instructions

  1. Create a folder in your Desktop or any other designated location on your machine; you can name it git-github-and-terminal
  2. Initialize a git repo inside that folder with the command git init
  3. Create a repository on git.generalassemb.ly - Your Github Enterprise Account
  4. Add your remote from github to your local repo with the following command: git remote add origin https://www.git.generalassemb.ly/YOURUSERNAME/git-github-and-terminal.git
  5. Create a file called README.md inside your git-github-and-terminal folder
  6. Write your answers to the questions below in your README.md file
  7. Commit your work at each point when directed (remember to git add . and then git commit -m "your commit message")



Git & Github - Questions

Refer back to the notes from today and/or use the internet and google-fu to find the answers to the questions below:

Answer the following questions

  1. What command do you use to setup a git repository inside of your folder?
  2. What command do you use to ask git to start tracking a file?
  3. What command do you use to ask git to move your file from the staging area to the repository?



Terminal Practice


Episode X: A New Terminal

A long time ago in a Unix environment far, far away, young Jedi padawans who knew only of desktop software were seduced by the dark side of the Force to enter… The Terminal.

Follow the instructions below using all the console commands introduced in Fundamentals, class, or that you find on your own.



Setup

  • Open the Terminal app
  • Inside your homework folder, git-github-and-terminal, create another folder called: galaxy-far-far-away
  • Then create a file inside galaxy-far-far-away called commands.txt
  • Paste the answer to each numbered question (i.e. the command(s) that accomplished the task) in commands.txt once you get it to work
  • Remember, you can learn about any Unix command by typing man and then the command name. E.g., man ls. Type Q to get out of the Manual page ("man page") viewer


Part I: Set the Scene

Complete all work inside the galaxy-far-far-away folder.

  1. Create a directory called death_star, and make the following files inside of it: darth_vader.txt, princess_leia.txt, storm_trooper.txt
  2. In galaxy-far-far-away, make a directory named tatooine and create the following files in it: luke.txt, ben_kenobi.txt
  3. Inside of tatooine make a directory called millenium_falcon, and in it create: han_solo.txt, chewbaca.txt

Part II: mv - rename

You can rename a file using the mv command.

  1. Rename ben_kenobi.txt to obi_wan.txt

Part II: cp - copy

You can copy a file from one location to another using the cp command. (man cp for more info)

  • Directories can be sibling (parrell to each other) or can be parents (the folder that contains the folder you are in)
  • Copy storm_trooper.txt from death_star to tatooine

Part IV: mv - move

You can use the mv command to move files from one location to another. mv can be used for renaming, moving, or both. Run man mv to see the options—remember hit the Q key to get out of the manual page viewer.

  1. Move luke.txt and obi_wan.txt to the millenium_falcon
  2. Move millenium_falcon out of tatooine and into galaxy-far-far-away
  3. Move millenium_falcon into death_star
  4. Move princess_leia.txt into the millenium_falcon

Part V: rm - remove

BE CAREFUL WITH rm!!! THERE IS NO "TRASH" IN THE UNIX CLI. WHEN YOU DELETE SOMETHING IT IS GONE FOREVER!!!

You can use rm to delete a file.

  1. Delete obi_wan.txt.

Part VI: all together

  1. In galaxy-far-far-away, make a directory called yavin_4
  2. Move the millenium_falcon out of the death_star and into yavin_4
  3. Make a directory in yavin_4 called x_wing
  4. Move princess_leia.txt to yavin_4 and luke.txt to x_wing
  5. Move the millenium_falcon and x_wing out of yavin_4 and into galaxy-far-far-away
  6. In death_star, create directories for tie_fighter_1, tie_fighter_2 and tie_fighter_3
  7. Move darth_vader.txt into tie_fighter_1
  8. Make a copy of storm_trooper.txt in both tie_fighter_2 and tie_fighter_3
  9. Move all of the tie_fighters out of the death_star and into galaxy-far-far-away

Part VII: rm -r: remove directories and everything they contain

BE CAREFUL WITH rm -r THERE IS NO TRASH CAN IN THE UNIX CLI. WHEN YOU DELETE SOMETHING IT IS GONE FOREVER

Before you hit enter, make sure are deleting the right thing, or you could accidentally delete the contents of your computer (it has happened).

This command will not typically ask you if you "really want to delete." It will just delete.

  1. Remove tie_fighter_2 and tie_fighter_3

Part VIII:

  1. Touch a file in x_wing called the_force.txt
  2. Destroy the death_star and anyone inside of it
  3. Return x_wing and the millenium_falcon to yavin_4

Celebrate. You've reached the end of this homework :)


Commit and push your updated code:

"Add" your changes (prepare them to be "committed"):

$ git add -A

"Commit" your changes—any time you make a commit, you can always restore the files in the repo to that point:

$ git commit -m "Completed homework"

"Push" your commits to github:

$ git push origin master