Merge to git repo

Jeg hadde to git repo’er på samme maskin, men i ulike kataloger.

Det som var ønskelig var å merge disse to repo’ene sammen til ett, slik at all historie ble tatt vare på. Dette kan gjøres da på følgende måte:

Git repo 1:

/sti/til/repo1

Gir repo 2:

/sti/til/repo2

cd /sti/til/repo1

git remote add -f repo2 /sti/til/repo1

git merge -s ours -no-commit repo2 repo2/master

git read-tree --prefix=dir-B -u repo2/master

git commit -m "kommentar til mergingen"

Dermed kan en slette ett av repoene, og samtidig ha en historikk over filene i et felles git repo.

git-cola in Windows 7

I have Windows 7 on my computer, but needed to run a git gui tool for our project. Searching on Google I found several, but they all were software for Linux. We have plenty of Linux Redhat servers, but no one running X window.

I installed then a Xming X server (http://sourceforge.net/projects/xming/) on my Windows 7 computer, and by configuring Putty (also a Windows program) and the sshd_config on the Linux server I could run git-cola and other Linux software in my Windows enviroment:

git-cola3

Putty configuration:

Connection -> SSH -> X11:

Enable X11 forwarding = true

X display location: location:0.0

 

Linux Redhat server configuration:

 

Also I noticed if I changed to another user in Putty (SSH) with:

sudo su –

then I wouldn’t be able to forward any X program. So, just after loggin in to the server in Putty with SSH, I had to start the program right away:

 

 

References:

 

 

 

Remove branch in remote git repo

If you have a remote git repo, and you want to delete a branch there, you can do:

Move a local git repo to a remote repo

Challenge: one have a local git repo on a Linux server where a big bunch of commit’s have been done. Now one want to put all the files and commits on a remote server, for more easier sharing with other.

Here is how it might be done:

First create the remote repo. We use gitolite-admin, where we add typically:
# Explaination of the repo
repo path/to/remote/git/repo
RW+ = adminuser
RW = user1 user2 user3

then,

git push

Now, since there is already a local git repo on the server with commits, we need to switch to the remote repo.
Check that there are no remote:
git remote -v
should not show anything, then:
git remote add origin git@git.uib.no:path/to/remote/git/repo

and possible this one too:

git branch --set-upstream master origin/master

What I had to do now, was to clone the remote repo I created with gitolite-admin in another directory, create a dummyfile, and push it. Then I could push and pull the local repo.
So:
cd /tmp/
git clone git@git.uib.no:path/to/remote/git/repo
vim dummyfile
git add dummyfile
git commit -m "dummyfile" dummyfile
git push origin master

Then:
cd /back/to/the/local/repo/you/want/to/clone/to/remote
git pull
git push origin master

I guess there must be an easier way, but I am no Git master…

Or, one can also do it in this way:

cd folder/
git init
# make a lot of files, add, commit and so on..
# REMOTE GIT REPO AVAILABLE AT git@something.url.edu:sys/path/remoterepo.git
# First push files to remote repo
git push --remote git@something.url.edu:sys/path/remoterepo.git
# clone the remote repo into a new folder
cd ..
git clone git@something.url.edu:sys/path/remoterepo.git folder2/
mv folder/ folder-old/
mv folder2/ folder/
# Test, everything ok? If so:
rm -rf folder-old/