Git is one of the most popular source code repository. To setup the first client and git server, some of the operations need to done simultaneously. We used centos server and two clients (one windows and the other one mac). Setting up the GIT server is sometimes tricky (obviously compared with mercurial and SVN). I had to go through a number of resources to actually identify what steps I have to follow.
Server Side
1. Install Git on Server
sudo yum install git
2. Setting up GIT configuration on the server
git config --global user.name "Tahsin"
git config --global user.email tahsinz@gmail.com
3. Set SSH user credentials
sudo adduser git_user
passwd git_user (Set password git77)
Main Client Machine (Windows )
1. Download and install tortoiseGIT
2. Download and install msysgit, a build environment for Git for Windows. http://msysgit.github.io/
3. Right click on any folder -> browse toritoisegit -> setting
4. Click git and provide git user info
name : Tahsin Zulkarnine
email tahsin@tahsinz.com
5. Download putty Key Generator
6. Getting ssh keys:
- Open puttygen
- Click generate key
- User key passphrase (tahsin).
- Save private key, public key and copy the key from top textarea (this will be used in next step).
Server Side
4. Setting up ssh authentication
a. Set environment
cd /home/git_user
mkdir .ssh
cd .ssh
touch authorized_keys
b. Set SSH Keys (how to find it plz check below)
emacs rsa.pub
paste key (found from main client) and save: ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAqxWId2AW8CuvRqgpomN+cgEvNDngZtwV9EnD+ezDtyzqkjsGPoEvzIiV845dOhvg883Zw3N0r8u5UkQc1yw3ZjuB8WZhoRLIUwy5uNMhMZCJvq5YHLHjCljgJ2mIO5doSXw7DwkZqQIb2QIk54+mVjHltSqv8YVfI8CIoscAXm0= rsa-key-20140210
cat rsa.pub >> authorized_keys
5. Create the project
cd /opt/
mkdir repo/
cd repo
mkdir test
cd test
git --bare init
cd ..
chown -R git_user test
chgrp -R git_user test
cd /opt/
mkdir repo/
cd repo
mkdir test
cd test
git –bare init
cd ..
chown -R git_user test
chgrp -R git_user test
Main Client (Windows PC)
1. Create a new folder test and Right click on test folder and click git init here. You will find a new folder named .git
2. Add some files to the folder. Suppose test.txt in that folder
3. Right click on test folder and click tortoisegit -> add . Add the files you want.
4. Do a commit. Right click and click git commit tool. Type commit message “First file to commit”.
5. Click git bash and type
git remote add origin git_user@centos_server:/opt/repo/test
git push origin master (It might give you warning: remote host identification has changed. If so Add the fingerprint of remote host provided in the message in your message location.)
Clone PC (Windows)
1. Create a folder test_clone.
2. Right click on the folder and click git clone
3. Provide credentials and url
URL: tahsinz@staging.tahsinz.com:/opt/repo/test
Directory: C:\xampp\htdocs\test_clone
4. Pull all the changes from the repository. Right click -> TortoiseGit -> pull. Give the credentials required.
5. Add one fine test_from_clone.txt.
6. Click git bash to commit and push changes. Type
git commit -am "Something"
git push origin master
Clone PC (Mac Os)
1. Download GitEye from http://git-scm.com/downloads/guis and install
2. Add repository: Server->staging.tahsinz.com, repo path -? /opt/repo/test, protocol -> ssh, user -> git and password. Click Next.
3. It will show master branch, select and proceed.
4. Select the destination where local repository will be located/saved.
You can now see two file in the test GIT Repository. You can browse by right click on the folder -> TortoiseGit -> Repo Browser.
You can see the git history by right click -> Git History.
Changes repository in future. TortoiseGit -> Settings -> Git -> Remote -> Origin