Code Repository P Blanchfield
Local Copy Methods There are two main ways of handling Code Repositories Local copy Remote only When you have a remote only system like SVN You copy to your local machine But you have to commit to the remote machine. When you have a local copy of the repository You clone the origin repository You can create new branches on your own copy You can add to your local copy of master and/or your local branches Then you commit them locally Then push them to the on line repository 2
Major advantage You can commit role back and merge branches on your own computer So you can still work where there is no Internet connection You don t get in danger of disturbing other people s work with your failure Until you sort yours out But you must regularly push back to the origin So that differences can be found and resolved. 3
Using GitHub GitHub is a version of Git It has advantages And disadvantages over other implementations We have GitLab available in the school https://projects.cs.nott.ac.uk/users/sign_in You get GitHub at https://github.com/ The advantage of using GitHub is that the world can see your work The advantage of using our GitLab is that the world can t Though you can make private repositories on GitHub now without paying 4
There is also BitBucket https://bitbucket.org/ I have never used it It used to have the advantage that free users could do private repositories It is still a Git repository and git commands work with it 5
Git Commands That means git documentation https://git-scm.com/documentation Works for github, gitlab and bitbucket Personally I prefer the GitHub layout Also GitHub for windows can be really useful https://desktop.github.com/ It will set up your projects with an SSH key without you having to work at it You can then use Poshgit as a command line access to your local repository However GitKraken is a better windows local git interface https://www.gitkraken.com/ 6
So what to do? Choose Git for your repository solution But keep it online where you like Locate your local repository somewhere safe I usually make a local repository in a workspace directory This was a habit from GitHub for Windows it does not need to be here Then I clone my repositories to this place 7
The easiest way Load GitHub and get a user account I will demo this in class Download GitHub for windows to your local machine Select PoshGit as the one you want Or Download GitKraken Make the connection to your on line repo. 8
Those of you who have not done it before, though I think most of you are set up already When using GitHub To clone your software If you have set it up through GitHub for Windows Click on the button clone or download Choose open in desktop Otherwise In your git command window Type ssh-keygen 9
Copy the public key Open in a text editor here I use Notepad and copy all. 10
On the GitHub page Select your profile And click on the settings option 11
On the settings page Select SSH and GPG keys then New SSH key 12
Next Name your key And paste the public key in ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCiAb2NEVohYrk57SQQnId5c7ZHp8 6JMSQJF6ppkM9FPX2RkKFvsxz/tafMNWjU2p0t7IC8McJnARCLvh1w0bDxkE 8UPTiMM+wBzW6tj90vGwJT5g/f6MpRKa6NrhZ/JiLlM/c2rYhc2pvMwcZQUlao BezjgR+5mpl/8aYEoPxD3RwU1IeeUkj9bZlRmbpIPvWvHFMNgPXu4uuO/sCP EP6FaUsBoFPA+Hn1WJm4YaetCSh4DJAXEeRS+pJCuDYy9SGimyXQaVVrBm 7TSELLN45Y+qVb/pz1LxIq87Ux38xBsLYlPRdlIwqj4U6fDib9fIe+Q1oGNyVoz C8yBOh4/bRh pxb@orkney 13
Now back to the project repo And select download again This time copy to clipboard 14
Back on your git shell This time open it And go to the workspace or wherever you have your working directory Type git clone then paste the repository location 15
Empty Repository Actually you may have an empty repository If all you have done is set it up and clone it Good to have a ReadMe.md file to explain what you are doing Good place to: Describe your project Mark up what the requirements are Also link to other repositories Documents etc. Can also create a Wiki and a related Web page You can create your ReadMe on your desk top And make your first push 16
In a git shell You git add * git commit m created a ReadMe git push origin master In GitHub for windows there is a synchronise button In GitKraken you can do it visually Note in posh-git the colours tell you things Red stuff has changed and not been added Green added but not commited 17
Now on GitHub You should be able to see what you have done (press refresh if necessary) 18
Graphs are useful The one I like most is the network On GitHub choose the Graphs tab and select network Nothing much to see yet but it will be quite helpful later on 19
On GitLab You get the same graph in the Repository tab under Network 20
If you use GitKraken The network is visible from the desktop And it updates when the origin repository changes 21
Now let us add some code Actually I am going to set up a Unity project first The first thing I did was to create a subfolder 22
I need to create a Trello To plan my project 23
I start with the backlog Subdivide the objectives Prioritise them Customer job Estimate times Programmer/designer job I have only started the process Colours show the type of task Yellow done in Unity Red done in C# code 24
Now allocate tasks I am the only developer so guess it is me I check out the task I want to start with and set one to doing I have set myself a due date of Feb 16 th for this, having set Feb 28 as the Sprint deadline. 25
But first I will create a new branch I want to keep all my developments separate So the one for creating the board I am going to put in a branch called AddBoard You may want to use a system that tells you who did what In a git shell I enter git checkout b AddBoard -b allows it to create a local branch 26
Now start Unity My first Test is Can I make a square and set up an orthographic camera And see the square from the camera. I make a new project in my workspace I save a scene I add an orthographic camera I add a new material I add a directional light I colour the material I look at the game view Can I see the square No adjust square position repeat Yes task comlete 27
I can now mark this test As completed on the Trello Notice I have also realised I needed to program the squares and other graphics 28
As I passed the test I now add and commit this to the branch In git shell I type git add * To add my changes Git commit m Created a square To commit them I will now push them so I can Continue at home git push origin AddSquare This will add the branch to the on line repository 29
On origin Branch AddBoard now exists 30
On origin There is a lot more stuff 31
However I don t have a git-ignore file Unity will create large numbers of files I don t need to save Like large numbers of binary files 32
Back on the Trello I realise it is most sensible to do one of the pure coding tasks next Creating the board square class Use case the board should have an array of 52 squares Each of which has a position, and occupation value 33
So I Set up the use case on the Trello And add the description of the Unit Test 34