Changes

Jump to navigation Jump to search

Workshop: Introduction to version control

2,056 bytes added, 18:26, 19 February 2018
Merge with "Version control
'''Version control''' is a technique for managing the complexity of adding and modifying information to a project.
 
When a project is in its infancy, it is fairly straightforward to keep track of the files contained within; it can, however, become unmanageable very quickly - especially if revisions happen frequently. Version control can be imagined as a series of '''snapshots''' of a project's revisions as time progresses. Each snapshot allows you to see exactly the state of the project at that time; each time you take a snapshot, you are adding another node to its history. You can travel back to any of these snapshots at any time.
 
The version control information (the files, the snapshot information, et al.) are held ''locally'' in a folder called a '''repository''', or repo. You can additionally sync this repo to a server somewhere else - called a '''remote'''. This can serve as a backup, as well as a way to ''share'' ''the repo with others'' who may also be working on the project.
 
A '''version control system''' (VCS) is a tool that handles all of this complexity: the repo itself, the snapshots, the remote(s), et al. There are many VCs's; the most popular is called '''[https://git-scm.com/downloads git]'''.
 
=== Terminology ===
'''repository''': the location and contents of a project, including all version control information
 
'''commit''' '''(n)''': a particular snapshot of a project
 
'''commit''' '''(v)''': to take a snapshot of a project
 
'''remote''': a copy of project, stored on a server somewhere else
 
'''branch''': a particular timeline of snapshots - the main branch is typically called "master"; other branches may be used to develop new features without risking the master branch's stability
 
=== Why use version control? ===
The two advantages that version control provides:
# ''You are able to travel back in time to any point in a project and utilize it from that moment''; and
# if you use a remote, ''collaboration is not only straightforward, it is encouraged''.
 
== Utilizing version Control ==
Why use [[version control]]? The two advantages that version control provides:
# ''You are able to travel back in time to any point in a project and utilize it from that moment''; and
'''This page's examples assume you are using git.'''
=== Required tools ===
* A VCS - preferably '''[https://git-scm.com/downloads git]'''.
* A web-based system to host your remotes. ** [https://bitbucket.org/ Bitbucket] is recommended because it offers free private repos for small teams, but .** [https://github.com/ Github] is the most widely used web-based repository.
Git is accessed through the command line interface (CLI) of your choice:
*''Windows'': you can use Git Bash (which was installed when you installed git.)
*''Linux/OSX'': terminal (which is installed with the operating system)
=== Setting up a repo ===
There are several ways to do this; the easiest way is to create a new repo on Bitbucket or Github, and then duplicate it on your local machine using a CLI of your choice:
# Navigate to the place you'd like to save the repo folder: <code>cd [path]</code>
You can now begin adding files in your repo!
==Using =Working with a repo===
==== Typical workflow ====
When working on a project ''locally'', your workflow will typically consist of the following:
#'''Modify''' files within the repository's folder (e.g. changing lines of code).
#'''Push''' the new commit to the remote repository: <code>git push [remote name] [branch name]</code>
=== Common git commands ===
{| class="wikitable sortable mw-collapsible"
!Command

Navigation menu