Skip to content

Instantly share code, notes, and snippets.

@Egget
Last active November 24, 2017 08:05
Show Gist options
  • Save Egget/76da98f69d36dc1db275661c439129c9 to your computer and use it in GitHub Desktop.
Save Egget/76da98f69d36dc1db275661c439129c9 to your computer and use it in GitHub Desktop.

Lecture by Kivra - Terminal and git

Terminal basics

  • Start the terminal
  • Filesystem (cd, pwd, ls, tree) How does paths work!?
  • Create files (mkdir, touch)
  • Remove files (rm)
  • Move and copy (mv, cp)

Terminal advanced

  • Run commands like you're the boss (sudo)
  • Install applications (aptitude, brew)
  • Run programs (npm, less, tail, man)

Git basics

  • Download project (clone)
  • Commit changes (add, commit, push)
  • Get latest changes (pull)

Git advanced

  • Create branches (branch)
  • Merge branches (merge)
  • Handle conflicts

Terminal basics - Assignments

Terminal for windows (with git)

Assignment 1 - Create your project structure

  • Create a directory called mydir (mkdir)
  • Move to that directory (cd)
  • Create a file called text.txt (touch)
  • Create a directory called code (mkdir)
  • Create a file called index.js inside code (touch)
  • Create a file called tests.js inside code (touch)
  • Create another directory called docs (mkdir)
  • Create a filed called mydocs.pdf inside docs (touch)
  • Rename the directory mydir to myapp (mv)
  • Create a directory called img (mkdir)
  • Copy an image (from your computer) into img (cp)

tree mydir (from the top) should show this:

myapp
├── code
│   ├── index.js
│   └── tests.js
├── docs
│   └── mydocs.pdf
└── img
    └── some_image.jpg

3 directories, 4 files

Assignment 2 - Install Node, npm and git

Install brew for mac

Install node

  • Install git (brew install git)

Assignment 3 - Make your project into a git repository

Rembember to check the status of your repository from time to time (git status)

  • Go to github.com and initiate a repository
  • From myapp, initiate a github repository (git init)
  • Add your files to be commited (git add)
  • Commit them with a fitting message (git commit)
  • Add your remote github repository (git remote add origin)
  • Did it work? (git remove -v)
  • Push your commit to the remote repository (git push origin master)
  • Remove your project from your machine (rm -rf myapp)
  • Clone your project from your newly created repository (git clone)

Assignment 4 - Use feature branches

  • Create a new feature branch for you to work in (git branch)
  • Checkout your new branch (git checkout)
  • Remove this branch (git branch -d)
  • Recreate the branch and checkout in one step (git checkout -b)
  • Open code.js in your favourite editor. Add some code. Commit it. (git add, git commit)
  • Checkout master (git checkout)
  • Open code.js, add some other code. Commit it (git add, git commit)
  • Now merge the master branch with your feature branch (git merge)
  • Gosh darn! We have conflicts. Resolve them using your favourite editor (git add)
  • Push your resolved code (git push)
@vpegado
Copy link

vpegado commented Nov 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment