This is a set of reminder instructions for how to use Git.
Git is a decentralised version control system created by the inventor of linux. It allows you to track changes from multiple remote develops into a master branch.
You can have a local repository (repo) and a remote one, hosted by something like Github.
The principle is you take snapshots of files using a process of 'commits'.
http://git-scm.com/download/win
This automatically downloads a command line interface called GitBash.
Add a new project. Create a folder in the file structure where you want to store the project.
Right click on the file and 'open bash here'. This opens bash in the right working directory.
Create the files you need.
$ touch <filename.extension>
e.g. $ touch mywords.docx
Open the files in whatever editor you want e.g. Atom and make and save changes.
In Bash, initialise an empty local git repo.
$ git init
Add files to the repo:
- $ git add
or:
- $ git add .
To add all the files at the same time. This moves files into the 'staging area'. You can check which files are here using:
$ git status
To remove files from the staging area:
$ git rm <>
There may be files which you don't want to commit to the master branch, e.g. log files, error files etc.
In this case, create a .gitignore file:
$ touch .gitignore
Open the gitignore file within the editor, then list the names of the files you don't want committed e.g. log.txt
Save.
When you next commit the files inside the .gitignore won't be uploaded.
To create a branch:
$ git branch
To switch branches:
$ git checkout
To merge branches:
$ git merge
To commit the files in the staging area to the repo:
$ git commit
This brings up an editor which encourages you to comment on your commit changes.
Use 'i' to edit the text, then esc, then : wq to exit.
To not do this each time:
$ git commit -m 'comments in here'
For remote repos (Github).
Create an account and sign in.
Make a new repo.
When you create a new repo it lists the url which you can copy and paste into your local repo to link.
$ git remote this lists the current remote links within the local repo
$ git push -u origin master this will push your local repo master to the remote github repo via a login screen
Create a README.md file for your repo.
$ touch README.md
Then edit, add, commit, push.
$ git push
$ git pull this will get all the changes made from your master remote repo to your local repo
To clone a repo from github, click the clone button which gives you the url.
Create a folder where you want to store it, open gitbashhere +:
$ git clone