Source Control

In order to manage your own code and share code with others you need to use source control.

Git

Git is the standard version control system for open source and professional projects. It is a distributed system (@todo expand).

You can view our projects on Github/CodeHub

Using git is easy once you know how! You just need to know the basic concepts and commands to get going.

Useful Git techniques + other resources

Installation

sudo apt-get install git

How to download code

So you've seen a great project on github repository and you want to download a working copy and take a closer look. This is called 'cloning the repo'. Go to the repo github page click the 'clone or download' green button and copy the link. Then enter the following command:

git clone https://github.com/CodeHubOrg/organisations-database.git

This will download the code to a directory called organisations-database, you can add a custom directory name as an additional parameter if you need to.

How to save your code

cd [your project path]
git init 
git add .
git commit -am 'Initial Commmit'

Then create a repo on your github account and follow the instructions to push your changes.

Git Workshop

Work through the git workshop to get used to the commands.

npm install -g git-it
git-it

Branches are cheap!

Branches are cheap so use them! For example if you want to play about with a new feature or do a bug fix.

Config

The git config file is found in your project folder ./git/config

Pull Requests

How to make pull requests

How to Write a Git Commit Message

How to Write a Git Commit Message

Read Git Book Pro

Read Git Book Pro, it's free and awesome.

Useful commands

git log - show log
git status -s - show working directory status
git checkout [branch] - check out a branch
git checkout -b [branch] - make a new branch based on current branch
git add . - add all files
git add -u - add deleted files
git commit -am "[commit message]" - add and commit with message
git push [remote] [branch] - push changes to remote (typicall called origin) and branch name (main branch is called master)
git merge branch - merge branch into current one
git diff [commit ref 1] [commit ref 2] - show difference between commits
git rebase - Rewrite time!  (becareful!)

results matching ""

    No results matching ""