4,599 bytes added,
16:58, 27 February 2016 = Overview =
git is a version control management tool that is very cool but is a bit difficult to get set up and scary as it uses dos commands. The benefits really outweigh the cons. Firstly we need a server to do all this so... this doc outlines how to set up a server for a Windows environment for a team to work on a SaaS solution.
So lets get started
= Setup =
== The Infrastructure ==
Ok, we start with a server, which allows all the team members pop things into centrally.
This server gets IIS installed, which means you're going to have a c:\inetpub\wwwroot folder or something very similar (maybe even an Apache folder).
Ok, into that we put our project. It should all be working lovely as a web server.
== Get git going ==
Easily done and installed with all the default options.
https://git-scm.com/downloads
Now we have git on the machine and we have the ability to right click on our wwwroot folder and choose "git bash" from within Windows.
Make sure you're in the wwwroot directory
You'll then need the following commands
<syntaxhighlight lang="dos" >
git config --global user.name 'Administrator'
git config --global user.email administrator@allnone.ie
</syntaxhighlight>
Next we need to start the repository
<syntaxhighlight lang="dos" >
git init
git add .
git commit -m "Initial Repository"
</syntaxhighlight>
Now we have a git repository set up and ready to share.
Now... we are a developer on the server :( with all the files in there... so we make the server go off on a separate branch to reduce error messages about Administrator working on the master branch.
<syntaxhighlight lang="dos" >
git checkout -b OriginBranch
</syntaxhighlight>
Your server is now ready to rumble.
== Allowing Remote ==
Now we need to allow ssh connections with the server. This requires BitVise WinSSHD server which is really cool software. Install that bad boy and get the service started.
You can use the service on a different port, so work away if you need to. We set ours to something ... e.g. 9999
Now, we need to create some users. We're going to use Virtual Accounts, so we don't need to worry about AD integration for the moment.
Add the virtual account. Now you need to set the user up to use bash.
[[File:gitserver_001.png|800px]]
So you should now make sure that the Virtual Group is also configured, through Edit Advanced Settings.
[[File:gitserver_002.png|800px]]
So now you should be able to connect to your server from a remote machine.
== Remote machine ==
So we have a remote repository. We have an SSH server to allow connections to it. Now your remote machine can pull down your repository.
Install git on your local machine the same as your server.
Go to your local inetpub folder (not the wwwroot). Right click on the background and choose "git bash".
Now you set up your machine.
<syntaxhighlight lang="dos" >
git config --global user.name 'Your Name'
git config --global user.email your.name@allnone.ie
</syntaxhighlight>
and if you like using Notepad++
<syntaxhighlight lang="dos" >
git config core.editor "'C:\Program Files (x86)\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
</syntaxhighlight>
Now we can get the repository onto our machine.
<syntaxhighlight lang="dos" >
git clone ssh://your.name@serverip:port/c/inetpub/wwwroot
</syntaxhighlight>
Your repository should now build into your wwwroot and you can test it locally.
Hey presto, you're up and kicking.
== Checking it is working ==
So now you have files downloaded... right click on the white of wwwroot and choose "git bash"
=== Create a branch ===
<syntaxhighlight lang="dos" >
git checkout -b Demo1
</syntaxhighlight>
add a file somewhere in wwwroot... go on hide it!
<syntaxhighlight lang="dos" >
git status
</syntaxhighlight>
You should see your file in the list
<syntaxhighlight lang="dos" >
git add .
git commit -m "Demo1"
</syntaxhighlight>
=== Merge back into master ===
<syntaxhighlight lang="dos" >
git checkout master
git merge Demo1
</syntaxhighlight>
we check for updates
<syntaxhighlight lang="dos" >
git fetch
git merge
git commit -m "Demo1a"
</syntaxhighlight>
we put it back into the master
<syntaxhighlight lang="dos" >
git push
</syntaxhighlight>
=== Remote machine update ===
Now all the data is actually on the server, but it isn't live yet...
Here is a handy batch file
<syntaxhighlight lang="dos" >
@echo off
cd \
cd inetpub
cd wwwroot
git checkout OriginBranch
git merge master
PAUSE
</syntaxhighlight>
[[Category:Topic:Useful]]
[[Category:Topic:General]]