Category Archives: git

clean up local repo

delete branches already deleted in remote repo

witr$ git remote prune origin

list local branches and theirs on remote : helps to see which local branch references to deleted remote branch

witr$ git branch -vv

delete branch referencing to deleted remote branch

witr$ git branch -d branch-to-delete

local clean up

witr$ git clean -dfx

extract git repository sub-folder as new git repository

Problem :

we have a git repository located in user@server:/home/witr/git-repos/witr.git
witr.git contains 3 projects: proj1, proj2 and proj3
projects are growing up. And cloning witr.git become too slow cause of the size.

Solution :
extract each project as a new git repository.
Follow steps bellow to extract proj1 (do the same for other projects).

1. on server : initialize new git repository proj1

2. on local machine : extract proj1 as new git

3. on local machine : ensure that all is right

=====================
local machine commands could be automated with following bash script

have your GIT server


=========================================== 31/05/2013
GIT:
Consists of two repository. one on server side and the other in client side (clone of server side repos).
When client commits, modifications were saved to client side repository
To send modifications to server, client must push commits.

1. install and configure git server
2. create server git repository
3. access to remote git repo with eclipse
4. explore git repository with gitk

1. install and configure git server:
sudo apt-get install git-core
git config –global color.diff auto
git config –global color.status auto
git config –global color.branch auto
git config –global user.name “mabrouk”
==> see your config in vim ~/.gitconfig

2. create server git repository
cd /home/mba
mkdir mbaGitRepo
cd mbaGitRepo
git init –bare

3. access to remote git repo with eclipse
Window->Show View->git Repositories
click on icon “Clone a Git Repository and add the clone to this view”
– Host : your host
– Repository path : ~/mbaGitRepo
– Conection : Protocol ssh / Port 22
– user: linux username (mba)
– password : linux user password
click Next
don’t worry of warning : Source Git repository is empty
click Next
Directory : Choose where you want clone the remote git repository in your local machine
click Finish

4. explore git repository with gitk
install gitk : sudo apt-get install gitk
launch gitk  : gitk