Github

Caporegime
Joined
24 Oct 2012
Posts
25,061
Location
Godalming
I see Github is quite a complicated beast, and as I'm having a day from hell, I'm hoping someone can answer a very basic question for me:

If I want to learn to code with a few friends and have a script which we can all access, is that what Github does? I read something about it a while ago but have no idea :confused:


Anyone?
 
Soldato
Joined
13 Jun 2009
Posts
4,230
Location
My own head
Well... it's a form of source control.

I would say it's the most accessible if you're sharing among friends, alternatives are things like SVN but I would argue that is more complex.

Basically you can have MASTER in git, which should be your "working" version of the code.

Each of you can then make branches i.e. Diddums branch, make some changes and then commit it up to github. From there you can then merge into the master.

If there are conflicts you'll need to manually resolve them, so say you and friend work on File.txt, when you commit you may need to make a new build and merge the changes and commit that up.

GITHUB private requires $$ unless you're a student, an alternative would be bitbucket which is an atlassian (jira) offering. Uses GIT protocols, but is free for private projects and you can invite your friends and build a project team :)
 

Pho

Pho

Soldato
Joined
18 Oct 2002
Posts
9,324
Location
Derbyshire
It's effectively a better way than using something like a shared DropBox folder, because if you all try and modify the same script at the same time things will get lost and go wrong. GitHub/source control in general are there to prevent this.

Use https://www.sourcetreeapp.com/ as a GUI frontend to manage your repository, push changes, get changes from others etc.
 
Soldato
Joined
25 Jun 2011
Posts
5,468
Location
Yorkshire and proud of it!
GIT is a piece of software for source control - tracking versions and branches (different variants of the code). Github is a public repository using GIT for people who don't want to host and manage their own. You can use it for a place that you and your friends can all work on the same code if you wish.

There are numerous different programs for controlling source / version control. SVN is another very popular one. It is much less popular today, but much simpler to understand. SVN works like a library with files as the books. People can check out (copy) the files and make changes and then put them back and SVN tracks every change made so that you can revert a change if someone does something stupid (which is what programmers do). If two people have both made changes, then what happens next is called a "merge" where you combine two people's changes. If they've both changed the same lines in a file, you get what is called a "conflict" and someone will have to sort that out by hand and decide what the right solution should be. Anyway, the metaphorical library in this case is called a "repository" and it lives on a server somewhere.

I started this explanation with SVN because it's reasonably simple to grasp. A central directory and some software to track when those files change.

GIT is more complex. It's popular because it can do some very clever things, but people can get in one Hell of a mess with it.

http://xkcd.com/1597/

Try to avoid getting sucked into the more advanced aspects of it. If you're just learning to program, you should really only need to learn a few things - how to "clone" a repository (i.e. getting a new copy of everything on your local machine to work on), how to "stage" files. This is something you do after making some changes locally and it's the preliminary step before you "commit" files. Committing changes is where you tell GIT that you're making a new version of the code. So if you fixed a bug, you'll "commit" your fix with a little message saying "bug blah has been fixed". Then you can see the history of all the commits and their messages in the log and do things like revert those commits if you find a mistake was made.

The final thing you need to understand to get the very basics down, is "pushing" and "pulling". You will have a clone of the repository on your local machine that you work on. When you have committed changes, they're still only on your local machine even though you committed them. To share them with your friends you'll need to "push" your changes back to the origin repository. Similarly, if someone else has pushed their changes up, they don't magically appear on your machine. You have to "pull" from the repository to get them. Which you'll want to do frequently to avoid everybody drifting too far apart and making conflicts more likely.

I've simplified a lot here. GIT confuses the Hell out of many people. So for example I've just told you to do a "pull" when really a "pull" is a shorthand for two separate commands ("fetch" to get the files and "merge" to combine the changes with your own) and sometimes people want to do these separately for various reasons. And I haven't really touched on Conflicts. But I've simplified for good reason. Learn to create repositories, learn to stage, commit and then push your changes, and that should be enough to get you started. The aim is to learn programming, not get into a frustrating experience with GIT. Learn about rebasing, stashing, reverting pushed merges, etc. later on. ;)

If you're just all trying to work on a single powershell script or something, just email it around. You'll lose a day just working out how to use GIT, what front-ends you prefer to work with it (or command line), etc. and it's a hassle you can do without. If you're writing more significant software, then by all means, create a repository on github and get stuck in. :)

Hope that helps.
 
Last edited:
Caporegime
Joined
28 Jan 2003
Posts
39,876
Location
England
We use but bit bucket at work and it confused the hell out of me as it was never explained tome how it works and then the guy who set it all up left.....
O.O

I then had to learn it on live systems. I only know the basics of commits and pulls etc.
 
Associate
Joined
18 Oct 2002
Posts
2,177
Location
Cardiff/Coventry
Used to be a massive Perforce fan (hell, I still use P4V for my main difftool!).

Then I started using Git. Spent a year swearing at it. Now I'd not go back to Perforce. It's awesome. Pretty steep learning curve, but it's a damn good bit of kit.

You can't half get yourself into some weird situations though with it. Even now I sometimes end up thinking what the **** at stuff - especially when merging branches!
 
Associate
Joined
7 Nov 2013
Posts
255
Location
Kent, England
alternatives are things like SVN but I would argue that is more complex.

More complex to use and less capable, I've helped 2 development teams away from SVN to Git and neither has regretted it. SVN has an awful branching/merge model and near useless if you ever work remotely or without repo access.

Once you get used to it and try all the different features out you can do some realy neat stuff.
 
Soldato
Joined
1 Mar 2010
Posts
6,306
It should also be noted that GIT was created by Linus Torvalds, who named it after himself.

cd5.png
 
Soldato
Joined
25 Jun 2011
Posts
5,468
Location
Yorkshire and proud of it!

The implication is that you think I'm joking. It really was created by him and when I saw him present it, that's exactly what he said. Totes true! :)

He also began his presentation by coming on stage and announcing that you didn't have to agree with him, but that if you didn't you were both ugly and stupid. Then he talked about the limitations of CVS for a while before insulting the audience some more. He's Finnish, you know. :)
 
Last edited:
Soldato
Joined
1 Mar 2010
Posts
6,306
The implication is that you think I'm joking. It really was created by him and when I saw him present it, that's exactly what he said. Totes true! :)

He also began his presentation by coming on stage and announcing that you didn't have to agree with him, but that if you didn't you were both ugly and stupid. Then he talked about the limitations of SVN for a while before insulting the audience some more. He's Finnish, you know. :)

Hmm, the mysterious G shall never be explained. The other maintainer is Japanese apparently. No Gs there either. :(


35029220.jpg
 
Soldato
Joined
1 Mar 2010
Posts
6,306
???

You've lost me. A "git" is a ******* in British slang. Hence why he told the audience that he'd named it after himself.

You know just the thread to put it into then. :) Not quite a joke, not quite a test, but it works!

Edit: Were you actually at the actual presentation?
 
Last edited:
Back
Top Bottom