Archive

Posts Tagged ‘git’

fastest way to get git server v2

March 19th, 2011 1 comment

Over a year ago I have posted instruction how to setup simple git server, today I had to do it again but already having code so here is new instruction.

Create remote repository:

ssh mpapis@niczsoft.com -C "git init --bare repos/library3.git"

Create local repository:

git init
git add .
git commit -m "initial commit"

Tell local repository to synchronize with remote repository:

git remote add origin mpapis@niczsoft.com:repos/library3.git
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git push

You might be interested in the original post: fastest way to get git server

Categories: Development, Hosting, Linux Tags:

my git prompt

May 26th, 2010 2 comments

After long playing around with my prompt I finally made it stable and thought it’s time to share :)

So edit your ~/.bashrc file and add following lines on the end:

shopt -s promptvars dotglob histappend no_empty_cmd_completion cdspell xpg_echo

function parse_git_dirty {
  echo -n $(git status 2>/dev/null | awk -v out=$1 -v std="dirty" '{ if ($0=="# Changes to be committed:") std = "uncommited"; last=$0 } END{ if(last!="" && last!="nothing to commit (working directory clean)") { if(out!="") print out; else print std } }')
}
function parse_git_branch {
  echo -n $(git branch --no-color 2>/dev/null | awk -v out=$1 '/^*/ { if(out=="") print $2; else print out}')
}
function parse_git_remote {
  echo -n $(git status 2>/dev/null | awk -v out=$1 '/# Your branch is / { if(out=="") print $5; else print out }')
}
export PS1='$(ppwd \l)\u@\h:\[33[33m\]\w\[33[0m\]$(parse_git_branch ":")\[33[36m\]$(parse_git_branch)\[33[0m\]$(parse_git_remote "(")\[33[35m\]$(parse_git_remote)\[33[0m\]$(parse_git_remote ")")\[33[0m\]$(parse_git_dirty  "[")\[33[31m\]$(parse_git_dirty )\[33[0m\]$(parse_git_dirty  "]")>'

I know it looks a bit complicated, unfortunately it is … this is wired bash rule that escape sequences are evaluated before evaluation of functions/variables evaluation.

Some examples of prompt using this script:

mpapis@papis:~/old_laptop/nicz-projects/content2:master> touch a
mpapis@papis:~/old_laptop/nicz-projects/content2:master[dirty]> git add .
mpapis@papis:~/old_laptop/nicz-projects/content2:master[uncommited]> git commit -m "added a file"
mpapis@papis:~/old_laptop/nicz-projects/content2:master(ahead)>git push origin master
mpapis@papis:~/old_laptop/nicz-projects/content2:master>

To make it more useful the prompt is also colored to distinguish between states of git repo.

For lazy users the script could be also replaced by very easy version, which prints git status before each prompt line (only where git is applicable):

export PS1='$(git status 2>/dev/null)\[33[0m\]\n$(ppwd \l)\u@\h:\[33[33m\]\w\[33[0m\]>'

Note: download the code from here http://niczsoft.com/files/2010/05/my-git-prompt.txt

Categories: Development, Linux Tags: , ,

fastest way to get git server

September 17th, 2009 Comments off

I was searching for a fast and easy way to setup git server, and I found one, but I was not fully happy with it, so lets have a look on another way:

ssh mpapis@niczsoft.com -C "mkdir -p repos/library2.git; cd repos/library2.git; git --bare init"
git clone mpapis@niczsoft.com:repos/library2.git
cd library2/
touch test.txt
git add .
git commit -a -m "1st"
git push origin master

This is good way to keep Your private repo, just as central repo or backup, no packages needed, just git on both sides

The same can be done on local filesystem like shared storage(nfs or smb):

cd /remote
mkdir test.git
cd test.git/
git --bare init
cd
git clone /remote/test.git/
cd test/
touch test.txt
git add .
git commit -a -m "1st"
git push origin master

From now on it will be working by simply calling “git pull” and “git push”.

Categories: Hosting, Linux Tags: , ,
Get Adobe Flash player