Skip to main content

Setting up GIT Server/Client

I was working my project today and came across GIT.
So wanted to tryout as I had heard a lot about GIT.
I am still learning about GIT this an initial doc to have anyone to get started.

Before you start, I recommend you to go through the video below.

Here is the link to GIT http://git-scm.com/

Few command you will see which are commonly used.
$ git init - Initialize GIT repository
git status - show status of the repository - modified files etc
$ git add - Adds file/directory to staging area (ready for commit/check-in
$ git reset - removes file from staging area (not ready for commit) - changes to file will not be affected.
$ git commit  - Commits data to repository (LOCAL repos)
$ git push origin -all - Push data from LOCAL repos to SERVER repos
$ git clone - Pulls data from SERVER to LOCAL repos


Setting up GIT Server
  • create a directory
ahmed@ahmed-work-horse:~/Desktop$ mkdir testGitProject
ahmed@ahmed-work-horse:~/Desktop$ cd testGitProject/
ahmed@ahmed-work-horse:~/Desktop/testGitProject$ pwd
/home/ahmed/Desktop/testGitProject
  • Next let create a git respos - server.
  • You will see all the information, (similar to as we see in svn server repos - Yes I am a SVN guy).
ahmed@ahmed-work-horse:~/Desktop/testGitProject$ git --bare init
Initialized empty Git repository in /home/ahmed/Desktop/testGitProject/
ahmed@ahmed-work-horse:~/Desktop/testGitProject$ ls -a
.  ..  branches  config  description  HEAD  hooks  info  objects  refs

Setting up client and pushing into GIT Server 
  • Setting GIT config information - Not very important but its good to have this.
ahmed@ahmed-work-horse:~/ahmed$ git config --global user.name "ahmed"
ahmed@ahmed-work-horse:~/ahmed$ git config --global user.email "ahmed@saggezza.com"
ahmed@ahmed-work-horse:~/ahmed$ git config --global color.diff auto 
ahmed@ahmed-work-horse:~/ahmed$ git config --global color.status auto 
ahmed@ahmed-work-horse:~/ahmed$ git config --global color.branch auto 
  • Lets Create a git repos locally (and later we will link this to our server).
ahmed@ahmed-work-horse:~/ahmed$ cd testGitProject/
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ ls
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ git init
Initialized empty Git repository in /home/ahmed/ahmed/testGitProject/.git/
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ git status 
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
  • As you can see this is an Empty Repositoty.
  • Lets create file readme.txt and add this to the respoitory.
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ vim readme.txt
  • Now you can see below once we have a file - but this is not add or committed to GIT.
  • we need to do this so that GIT will take care of version control. 
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ git status 
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
# readme.txt
nothing added to commit but untracked files present (use "git add" to track)
  • Now lets add this file to repos.
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ git a
add        am         annotate   apply      archive    
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ git add readme.txt
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ git status 
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached ..." to unstage)
#
# new file:   readme.txt
#
  • Once we add, file goes into a staging area, you can call this as ready to commit.
  • But still the file is not commited.
  • Now lets do that next.
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ git commit readme.txt
[master (root-commit) 6bf4daf] First Document !!
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 readme.txt
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ git status 
# On branch master
nothing to commit (working directory clean)
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ ls
readme.txt
  • Once we have commit you will see.
  • Number of files changed, number of lines updated/added, and number of files deleted.
Linking client repos to the server.
  • Now lets link the client repos which has the update to server.
  • Once we are done with this we can push (check-in to the server in SVN terms) data to server.
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ git remote add origin ssh://ahmed@172.16.2.15/home/ahmed/Desktop/testGitProject
ahmed@ahmed-work-horse:~/ahmed/testGitProject$ git push origin --all 
ahmed@172.16.2.15's password: 
Counting objects: 2568, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2506/2506), done.
Writing objects: 100% (2568/2568), 32.02 MiB | 4.05 MiB/s, done.
Total 2568 (delta 859), reused 0 (delta 0)
 * [new branch]      master -> master
  • Lets analyse the first line here.
  • git push origin --all This will push all the data into the server.
  • we are connecting to GIT server over SSH.
Testing the sever - if all izz well !!
  • Lets create a new directory and clone the respository (checkout in terms of SVN).
ahmed@ahmed-work-horse:~/ahmed$ mkdir testServerInformation.git
ahmed@ahmed-work-horse:~/ahmed$ cd testServerInformation.git/
ahmed@ahmed-work-horse:~/ahmed/testServerInformation.git$ ls
ahmed@ahmed-work-horse:~/ahmed/testServerInformation.git$ git clone ssh://ahmed@172.16.2.15/home/ahmed/Desktop/testGitProject
Cloning into testGitProject...
ahmed@172.16.2.15's password: 
remote: Counting objects: 2568, done.
remote: Compressing objects: 100% (1647/1647), done.
remote: Total 2568 (delta 859), reused 2568 (delta 859)
Receiving objects: 100% (2568/2568), 32.02 MiB | 24.71 MiB/s, done.
Resolving deltas: 100% (859/859), done.
ahmed@ahmed-work-horse:~/ahmed/testServerInformation.git$ ls
testGitProject
ahmed@ahmed-work-horse:~/ahmed/testServerInformation.git$ cd testGitProject/
ahmed@ahmed-work-horse:~/ahmed/testServerInformation.git/testGitProject$ l
readme.txt
  • Lets analyse the first command.
  • git clone ssh://ahmed@172.16.2.15/home/ahmed/Desktop/testGitProject
  • we are connecting to GIT server over SSH.
  • As you can see we see same respose been pulled out from the server (check-out).
  • Terms in GIT -- push to sever (check-in) and pull to server (check-out).
  • Please make sure that the GIT server accepts SSH connections.
  • To test this just do something like ssh ahmed@172.16.2.15 - this should log-you-in into the server
Getting GIT from GIT
$ git clone git://github.com/gitster/git.git

Thats it for now.
I will update this as I learn more information about GIT .. :)

Happy Coding !!

Comments

Popular posts from this blog

Cloudera Manager - Duplicate entry 'zookeeper' for key 'NAME'.

We had recently built a cluster using cloudera API’s and had all the services running on it with Kerberos enabled. Next we had a requirement to add another kafka cluster to our already exsisting cluster in cloudera manager. Since it is a quick task to get the zookeeper and kafka up and running. We decided to get this done using the cloudera manager instead of the API’s. But we faced the Duplicate entry 'zookeeper' for key 'NAME' issue as described in the bug below. https://issues.cloudera.org/browse/DISTRO-790 I have set up two clusters that share a Cloudera Manger. The first I set up with the API and created the services with capital letter names, e.g., ZOOKEEPER, HDFS, HIVE. Now, I add the second cluster using the Wizard. Add Cluster->Select Hosts->Distribute Parcels->Select base HDFS Cluster install On the next page i get SQL errros telling that the services i want to add already exist. I suspect that the check for existing service names does n

Zabbix History Table Clean Up

Zabbix history table gets really big, and if you are in a situation where you want to clean it up. Then we can do so, using the below steps. Stop zabbix server. Take table backup - just in case. Create a temporary table. Update the temporary table with data required, upto a specific date using epoch . Move old table to a different table name. Move updated (new temporary) table to original table which needs to be cleaned-up. Drop the old table. (Optional) Restart Zabbix Since this is not offical procedure, but it has worked for me so use it at your own risk. Here is another post which will help is reducing the size of history tables - http://zabbixzone.com/zabbix/history-and-trends/ Zabbix Version : Zabbix v2.4 Make sure MySql 5.1 is set with InnoDB as innodb_file_per_table=ON Step 1 Stop the Zabbix server sudo service zabbix-server stop Script. echo "------------------------------------------" echo " 1. Stopping Zabbix Server &quo

Access Filter in SSSD `ldap_access_filter` [SSSD Access denied / Permission denied ]

Access Filter Setup with SSSD ldap_access_filter (string) If using access_provider = ldap , this option is mandatory. It specifies an LDAP search filter criteria that must be met for the user to be granted access on this host. If access_provider = ldap and this option is not set, it will result in all users being denied access. Use access_provider = allow to change this default behaviour. Example: access_provider = ldap ldap_access_filter = memberOf=cn=allowed_user_groups,ou=Groups,dc=example,dc=com Prerequisites yum install sssd Single LDAP Group Under domain/default in /etc/sssd/sssd.conf add: access_provider = ldap ldap_access_filter = memberOf=cn=Group Name,ou=Groups,dc=example,dc=com Multiple LDAP Groups Under domain/default in /etc/sssd/sssd.conf add: access_provider = ldap ldap_access_filter = (|(memberOf=cn=System Adminstrators,ou=Groups,dc=example,dc=com)(memberOf=cn=Database Users,ou=Groups,dc=example,dc=com)) ldap_access_filter accepts standa