Getting started with Version Control/GIT

Hi All,
Sorry if this has been asked.

I am clueless as to where I should start with GIT, setting it up and learning how to utilize it within my own work. I have been developing websites for many years now but have never stepped into that realm.

Do any of you have any suggestions as to where I can learn about it and any guides to setting it up on a PC? I primarily do front-end development although occasionally dabble in back-end (PHP, MySQL).

Any help would be greatly appreciated!

Windows? Linux? Mac?

Depends on how low you wanna go with it. Git is a command line tool, but there are some nice GUI tools out there. If you’re on Windows/Mac there is http://www.sourcetreeapp.com/ and if you’re on Linux there is SmartGit (their site is 404ing for me right now).

The creators of Source Tree (and BitBucket, a great free online private repo) put out probably the best Git tutorial series I’ve seen. https://www.atlassian.com/git/tutorials/ I think it’s mostly command line based, but if you go through the Getting Started tutorial, you’ll get a good feel for it.

Git, and source control in general, can be intimidating at first. But you need it if you work with code and if you stick with it you’ll figure out it’s really not that complicated or hard, just a lot of things you can do with it.

There are also other forms of source control like Mercurial, SVN, Perforce, etc. Git is the most popular right now and for good reasons. It’s very powerful and very easy to use once you get going.

There are installers for windows on the official site.

http://git-scm.com/download/win

However, what I would highly recommend is using vagrant to set-up a virtual box to work in. That way the easy install of all linux software can be leveraged like php, node.js, ruby, etc. Not saying you need those things now but you might down the line. Some like node and ruby are painful to set-up on windows machines directly. For example, if you would like to use sass or less than ruby is required for the environment and that all becomes very painful to set-up on windows. How about grunt or bundler –the same node.js is also not really easy to set-up on windows. So the best thing you can really do upfront is use a vm when working on a windows machine but using open source none Microsoft technologies.

1 Like

@cpradio Right now I am using a Windows box but am setting up a separate boot for Linux tonight. I work on a mac at my office as well, so I am using all 3 in all actuality.

I would really like to learn the ropes with all this, and start using it from here on out. I find myself always wanting to revert back to certain things for testing purposes and seemingly getting lost in the amount of separate files I have. So all this version control stuff is starting to seem more and more plausible for me.

Thanks for the links, I will be sure to check them all out.

I find myself always wanting to revert back to certain things for testing purposes

You will need to get a good handle on branching then. It’s amazing for things like this.

Are you using an IDE that supports GIT integration? Such as Sublime, phpStorm, IntelliJ, etc. I installed GIT (from the link in @oddz post) on both Linux and Windows and my IDE (I’ve used phpStorm and now I use IntelliJ) then “assists” me with the integration – pulling from it, pushing to it, etc.

If you plan to use GitHub, GitHub for Windows is really interesting and easy to use. There is one for Mac too!

Resources:

https://learnable.com/hub/play/60

Book: (I think this one costs money…)
https://learnable.com/books/git-fundamentals/online/cover

I’ve read and can heartily recommend the Pro Git book. It’s very exhaustive and really teaches you all you need to know. You can read for free online, too!

I’ve been using the Adobe Creative Suite for the past 6 years (So Dreamweaver) but I have messed around with others (more recently Brackets).

I believe I have the GIT installed on Windows and I also have a plugin setup in Dreamweaver as I see a GIT menu at the top

I think my biggest questions are how do I use this for certain projects? So starting with my most recent client, we’ll call them “Client 1”

Is there some sort of step by step guide? I think that once I get a handle on it, it should all come to me but my biggest difficulty is getting the ball rolling, lol.

Yep, looks like I have GIT for Windows installed. Is this what you were referring to?

I think my biggest questions are how do I use this for certain projects?

Usually by creating individual repos for each project. Every once and awhile you’ll run into that crazy person who has multiple projects and just uses a single repo.

Is there some sort of step by step guide?

The guide I linked earlier is basically step by step using the command line.

Yep, looks like I have GIT for Windows installed. Is this what you were referring to?

That is GitHub for Windows. Not Git. I don’t think it can work as a regular Git client and can only publish to Github who doesn’t have free Private Repos, only public for open source. You probably don’t want to open source your client’s projects. Try Source Tree I linked above and create a Bitbucket account.

Derp! Yes, definitely don’t want to open source my clients websites, haha.

I’ll take a look and try to get this setup.

Off-Topic: Any suggestions for an IDE that ties well with GIT? As I said before, I primarily do front-end development.

Using GitHub for Windows
(note: as @mawburn stated, there isn’t any free private repos on GitHub, so you may want to use SourceTree – see next post)

Yep, from there you can create a repository, and import your initial set of code, for client 1 (if you like to have your projects separated by client).

So click the + sign in the top left corner,
Name: Enter the Client’s Name for the repo (using dashes instead of spaces)
Local Path: Navigate to the folder containing that client’s code

Click on Create Repository.

Now you have it created, DW may detect this if you close it and reopen it (I’m not sure about that as I’ve never used DW).

The above step should import all of the folders/files for your client’s site into your newly created GIT repo. As you make changes, you will need to commit them and push them to the repo (note the two steps, commit and push).

If you make changes somewhere else, or on a different PC and you commit and push them to the repo, you can then PULL them to your other PC (note: pull).

That is the “real real basics” of git. There is a lot more you can obviously do, and will do as you get in the habit of it, but this is enough to get your feet wet.

If you want to go all out, there is WebStorm by Jetbrains. I use IntelliJ and it’s Git support is great. Pretty much all Jetbrains products are top notch and the best full IDEs out there besides Visual Studio.

Besides that, I have heard good things about Brackets.io and I like Sublime. I don’t know how well git is supported on either. I tend to use SmartGit at home even though I could do it with IntelliJ. I like the histories, graphs, the merge trees, and the nice diff comparisons.

Using BitBucket with SourceTree
(let’s you have private repos at no cost)

Install Source Tree (see link above and create a BitBucket account)
Create a Repository in BitBucket for your Client/Project
Open Source Tree and click the Clone / New button
Select the Create new Repository tab
Repository Type: Git
Destination Path: Location of your current projects files.
Name: Whatever you would like to name the repository
Click Create

Once the Repo is created, you will have a lot of “Staged” files/folders. Click on the Add button to get them added to your repo.

Once all files/folders have been added, click on the Commit button, and use the message “Initial Import” (so you know when you started using GIT with this project) then click Commit in the bottom right.

Click on Repository > Repository Settings
Under Remotes, click Add
Type the name you want to use for this project
In BitBucket, navigate to your repository and click on Clone, change the drop down to HTTPS and copy the URL
Paste the URL in the URL/Path

Make sure the Host Type is set to BitBucket
Type your username in the Username field
Click OK
Click OK again

Now Click on Push
Make sure the remote name you just created is listed in the drop down
Check the Checkbox next to “Local branch”, it is likely called “master”
Click OK

If you navigate to the Commits section in BitBucket, you should see your project’s code.

1 Like

Here’s a interactive FREE online GIT course

I’m not quite sure why but most GIT users prefer to use it as command tool… For me, I just use IDE like Eclipse w/ GIT plugin. I really don’t see the difference between SVN/GIT/CVS. They all can check-in/check-out/compare/merge. Some even claims if you don’t use GIT, you’re not a real developer… Anyways, it is good buzz words to put in for your resume I guess.

2 Likes

I used SVN and Git on the same project (yeah, their old files were in SVN and the newer ones in Git, aarg), and the difference is, they’re completely different. Other than vaguely both doing version control, I can’t really see them as the same at all. The biggest difference was, there was (supposed to be) one SVN repo, and we had local copies. With Git there were multiple repos, every one who was working on the project. But actually since there had been upgrades of SVN twice before I’d started there, there were actually 2 SVN repos, one with some ancient version and one with like 1.7, both with active files. SVN done wrong, I suppose.

With SVN, I pretty much only ever pulled and pushed (mostly pushed). That was pretty easy. Merging was something we all avoided. Also, with our version, every fricking directory was filled with like a gazillion .svn’s. Arg, that sucked. I don’t think that problem exists in SVN anymore though.

Merging in Git was pretty regular, and at the time pretty easy, though the others used some weird graphical thing where you were supposed to grab chunks of text from one box and paste it in another box or something weird and follow little arrows… I just used my editor at the time because that made more sense to me.

Today I’m using Mercurial at work. I would strongly recommend people not use both of these-- they have the same command names which do completely different things. Since all my personal projects are on Github, this has caused me endless grief : )

2 Likes

I moved 7 posts to an existing topic: Feedback about SitePoint on Discourse

If you choose to use git sourcetree is a nice GUI. I use to do everything via the command line up until I was introduced to sourcetree. I’ve used svn and git. I much prefer git. Especially for projects with multiple developers. Git makes it very easy to branch and merge. So it isn’t as much of ahassle as it would be with svn to create feature branches, merge and resolve conflicts.