Get me going Revision Control setups

I’ve been making websites in a professional capacity for 10+ years now and my development tools haven’t changed much, a couple extensions here and there but it’s still just WAMP, notepad++ and Firefox(+addons).

I think I’m reaching an age where I’ve done so much work I can’t remember everything I’ve done/tried in the past for problems. I make a prolific amount of comments but that doesn’t document what I did and when.

I want to jump on the revision control bandwagon but when I have tried in the past it has not been a “download, install, use” procress. I don’t want to start with vast amounts of setup and messing around. I just want to get on with work.

What are some good, easy to get going, private/local, revision control setups?

Local I would not advise how I think you mean to say. I have a love hate relationship with GIT. For a single user, it is easy to use and keep track of code changes. When used in a team, it gets a little irritating, especially running on a windows environment. The Pro-Git book is free online so that is an added bonus. You can also do Bitbucket and Github for private repos, which gives an offsite location if something catastrophic happens to you local system.

Mercurial, is slightly easier to use, but, if you are working by yourself you still have less to worry about than a team used system.

Both give a full copy of the contents. So, if you pull the repo, it has a full history.

One reason to get on board is that you can more easily contribute to other projects if needed. It’s not too uncommon to hit some kind of road block when using a 3rd party script/lib. Being able to submit code to the project yourself (or at least forking it) is quite helpful. It of course also helps if you’re ever in the situation where you’re going to work on a project with a new/existing team. Without any numbers to refer to I feel it’s a high chance other projects/teams are using git already.

Git isn’t that bad to get started with, yes it has some strange sides to it - but your normal day to day usage will not be very complex at all.

I use git in command line, but there are also quite a few GUI applications available. If you want to use command line in Windows I suggest using something like CMDer (free). If you want to give it a go get the full package, you will then have ssh/git/etc available.

Cmder is a software package created out of pure frustration over the absence of nice console emulators on Windows.
http://cmder.net/

Get started
[size=8pt](if you’re not using CMDer or similar solutions you’d need to start with installing git)[/size]

$ git config --global user.email "[email protected]" $ git config --global user.name "your name"

Initialize a repository

$ git init

Add all files

$ git add .

Commit all files

$ git commit -a -m "some commit message"

View commits

$ git log --oneline

Revert (undo) commit

$ git revert <commit id>

That is basically what you need, as a one man band.

[hr]

Branching
For bigger projects I suggest you use branching, even as a single developer.

Imho branching gives you both a more visual feature history, and an easier way to include/exclude features in your project.

Ie you’ve made a calendar widget and a event list. You then realize you have to change one of them, or one isn’t working according to specs. If these features are in a mish mash of commits on the master (default) branch, then picking it out will be a nightmare. If you’ve made separate development branches for the features you can simply not merge it into the master branch, or if it’s already merged you can revert it in a single command.

Below is an example of how feature branches could be used to “containerize” development.

[ul][li]Every commit on the master branch is a release[/li]
[li]Features are made in their own branches and merged back into develop when done[/li]
[li]X number of features are then merged from develop into master to form a release[/li][/ul]

List branches

$ git branch -a

Create branch

$ git checkout -b branch-name

Merge branch feature-one into develop branch

$ git checkout develop (if you're not already on develop) $ git merge feature-one

Delete branch

$ git branch -d feature-one

[hr]

Hosted repo

I do strongly suggest you use a hosted service though, it makes collaboration easier, and you can rest assured your data is also “in the cloud” (had to get a buzz word in here). Gitlab has free private repositories, and you can even host it yourself - if you want. These services also have other features, like issue tracking, wikis, web ui for branching/pull requests/general git usage, etc.

To work with remote sources you need a ssh key to verify your identity. It’s recommended to protect the key with a password.

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

This creates two files
%UserProfile%.ssh\id_rsa is your private key which is not to be shared
%UserProfile%.ssh\id_rsa.pub is your public key which you need to add to services you want to use

Ie in Gitlab/Github/Bitbucket you have a “SSH keys” setting in your user control panel, where you must add the public key(s) you wish to use with the service.

After creating a project in the hosted service you can simply

If it’s a new project (you don’t have a local repository)

git clone https://gitlab.com/your-user/project-name.git cd new-project touch README.md git add README.md git commit -m "add README" git push -u origin master

If it’s a project you have started on locally (have a local repository)

git remote add origin https://gitlab.com/your-user/project-name.git git add . git commit git push -u origin master

Your local repository is now linked to the hosted repository. And you can

[ul][li]push commited changes from your local machine to the hosted service[/li]
[li]pull changes from the hosted service to your local machine[/li][/ul]

[hr]

Learn more

For more info I highly recommend Atlassians wiki, it has great information with visuals on how to work with git. Note that this goes to great depths though, so you might have to consider how “deep” you want to go.

It can also be helpful to play around with it visually, of which this is a great tool:
https://onlywei.github.io/explain-git-with-d3/

[hr]

Other

Other than git I highly recommend you look into using an IDE to make life as a dev easier.

A proper IDE will give you syntax highlighting, code completion and much more. I’ve written a post about it here: http://www.phphelp.com/forum/the-occasional-tutorial/make-your-life-simpler-use-an-ide!/

I can recommend PHPStorm (paid) and Netbeans (free)


how-to-use-git-branch-15-638[1].jpg

I have been using GIT GUI for windows. Simple to use. Just recently I got around to actually reading details of using it and much to my amazement I discovered when you switch branches, all the files in your working directory change to the files from that branch. I always thought you had to do a checkout to get the files, but working locally it doesn’t work that way.

On the IDE paid side, the best one (and I have used them all) is Webuilder http://www.webuilderapp.com/

Sponsor our Newsletter | Privacy Policy | Terms of Service