Tech Returners

Version Control




What is Version Control and why is it important?

  • Version Control (aka Revision Control aka Source Control) lets you track your files over time.
  • Version control is also the key to collaborative software development… 
    • you can work in teams on the same project easily
    • manage conflicts in code on the same files
    • work on different versions all at the same time
    • decide what you want to keep and what you want to bin

Why Do We Need A Version Control System (VCS)?

  • Backup and Restore - Files are saved as they are edited, and you can jump to any moment in time.
  • Synchronization. Lets people share files and stay up-to-date with the latest version.
  • Track Changes. As files are updated, you can leave messages explaining why the change happened (stored in the VCS, not the file). This makes it easy to see how a file is evolving over time, and why.
  • Track Ownership. A VCS tags every change with the name of the person who made it. Helpful for blamestorming / giving credit.
  • Branching and merging - You can branch a copy of your code into a separate area and modify it in isolation (tracking changes separately). Later, you can merge your work back into the common area.

GIT Vs GITHUB


Github



Git Github
a tool that allows creation of a local repository allows hosting the central repository on a remote server
a version control system a repository hosting service

GitHub terminology

  • Repositories - A repository is the most basic element of GitHub. They're easiest to imagine as a project's folder. A repository contains all of the project files (including documentation), and stores each file's revision history.
  • Branches - Branching is the way to work on different parts of a repository at one time.
  • Commits - A commit, or "revision", is an individual change to a file (or set of files). It's like when you save a file. Commits usually contain a commit message which is a brief description of what changes were made.
  • Pull Request - Pull requests are proposed changes to a repository submitted by a user and accepted or rejected by a repository's collaborators.
  • Branching and merging - You can branch a copy of your code into a separate area and modify it in isolation (tracking changes separately). Later, you can merge your work back into the common area.


timeline


GitHub Tour

Task 1 - setup a GitHub account

Task 2 - GitHub tutorial

Intro to the command line

  • It is a tool which you can type text commands into to perform specific tasks directly to the computer
  • Through typing, many tasks can be performed more quickly, and some tasks can be automated with special commands that loop through and perform the same action on many files — saving you lots of time in the process.
  • The computer will attempt to carry out any command that it understands. Unfortunately, the computer does not speak in any language spoken by humans
  • The people who have created the operating systems you work on have created a standard set of commands that are built into the computer without having to be processed.
  • The user interface that accepts your typed responses and displays data on the screen is called a shell and there are many different varieties that you can choose from.
  • Most common one is Bash which is the default on mac and Linux.
    If you are using Windows you can download git for windows at https://gitforwindows.org/

What can we do with Command Line?

  • Move around your file structure
  • Create and remove folders
  • Create and remove files
  • Copy and paste files
  • Rename files
  • List files
  • Run programs, servers etc
  • Can also Delete!! If you instruct the computer to erase all of your data, it will cheerfully proceed to do so.
  • KEY NOTE: Do not run a command just to see what it does.
  • Make sure you understand what the command is supposed to do first, especially if the command involves changing or removing files.

Git & The Command Line

  • Git is a very powerful and popular version control system, and the only place you can run all Git commands is from the command line.
  • If you know how to run the command line version, you can probably figure out any GUI versions.
  • Command-line tools are used by developers everyday, so it’s best to understand it for the future! :)

Task 2 - create a repository for your website on GitHub

Make some changes to your website and push up to github
https://git-for-windows.github.io/

Some useful git / git bash commands


Command Description
git init initialise a project for version control (do this from within the folder to be initialised)
git status see where changes have been made, but not yet added
git add . add all outstanding changed files into staging
You can specify a particular file if you don't want to add them all
git commit -m "{message}" commit change to git and add a relevant comment to identy changes made
These will be visible against all affected files in GitHub.
git log log of all commits
Note: you need to enter q (for Quit) to get out of the status window
git remote add origin {url} sets up connection to between repository on your PC and the one in GitHub
git push origin {branchname} sends code to the {branchname} branch on git-hub (usually master, but you have to specify)
git remote -v Shows you the target url of the repository on GitHub if you are connected
git clone {url} takes a copy from github and loads it on your pc
NB puts the code into a new folder
rm -rf .git Trouble shooting - delete local git repository
Very useful if you have cloned to the wrong location and want to remove the error. Remember to move / copy your changed code to a tempoaray location before you remove the local repository as it will be deleted!
pwd print working directory (show me the place in my folder structure that I am right now)
cd .. move up one level in my folder structure
cd - return to the last directory I was in (NB. This is a toggle setting)
ls list structure (equivilent to dir command in DOS)
ls -ltr same as ls, but shows details of file permissions, size, modification time and name, in reverse order
For a full list of list commands, type ls --help on the command line and test a few out
-l : use a long list format
-t : sort by modification time, newest first
-r : reverse order when sorting
mkdir Make directory (folder) - will give an error if it already exists
rmdir Remove (delete) a directory (NB must be empty)
A directory cannot be removed if it is still registered as a git project. use rm -rf .git to fix
rm delete file(s) from a directory
rm --help gives some assistance
e.g. you can delete all jpg files by typing rm *.jpg

Additional materials


Bootstrap is next...
Click the link Below