Home > GIT, Linux Command Line > GIT Reference

GIT Reference

Some day to day useful git stuff for system administrators,
1) Server side repository setup,

ssh reynold@git.jackal.com


[reynold@git ~/]$ cd public_git
[reynold@git ~/public_git]$ mkdir testrepo.git
[reynold@git ~/public_git]$ cd testrepo.git/
[reynold@git ~/public_git/testrepo.git]$ git init --bare
Initialized empty Git repository in /home/reynold/public_git/testrepo.git/
[reynold@git ~/public_git/testrepo.git]$ 

2) On local machine,

cd Projects/
git init
git config --global user.name "Reynold PJ"
git config --global user.email reynold@jackal.com
git remote add public reynold@git.jackal.com:/git/reynold/testrepo.git
git add testscripy.py
git commit -m "Added testscripy.py"
git push public master

Check url


3) Ignore local changes and reset to the one in origin/master,

git reset --hard origin/master
git pull origin


git checkout master
git merge master

4) Create a new branch, apply the changes in that branch and push the changes. When you are making changes to a shared code base, its always recommended to make your changes in your own branch and later merge it to the master branch.

reynold@jackal:~/git/chef-cookbook-couchdb$ git pull
reynold@jackal:~/git/chef-cookbook-couchdb$ git checkout -b reynold
reynold@jackal:~/git/chef-cookbook-couchdb$ git add attributes/default.rb
reynold@jackal:~/git/chef-cookbook-couchdb$ git commit -m "attributes/default.rb: Removed timewindow from auto-compaction"
reynold@jackal:~/git/chef-cookbook-couchdb$ git push origin


Merge the changes made in new branch ‘reynold’ to the master branch.

reynold@jackal:~/git/chef-cookbook-couchdb$ git checkout master
Already on 'master'
reynold@jackal:~/git/chef-cookbook-couchdb$ git pull origin master
From git.jackal.com:/git/chef-cookbook-couchdb
 * branch            master     -> FETCH_HEAD
Already up-to-date.
reynold@jackal:~/git/chef-cookbook-couchdb$ git merge reynold
Updating 0fdb954..7039a98
 attributes/default.rb |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
reynold@jackal:~/git/chef-cookbook-couchdb$ git push origin master
Total 0 (delta 0), reused 0 (delta 0)
To git.jackal.com:/git/chef-cookbook-couchdb.git
   0fdb954..7039a98  master -> master


Categories: GIT, Linux Command Line
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: