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:
Gir repo 2:
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.
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:
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:
If you have a remote git repo, and you want to delete a branch there, you can do:
# if you want to delete the branch locally first, do:
git branch -D branchname
# then also remotely
git push origin --delete branchname
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
RW+ = adminuser
RW = user1 user2 user3
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 email@example.com: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.
git clone firstname.lastname@example.org:path/to/remote/git/repo
git add dummyfile
git commit -m "dummyfile" dummyfile
git push origin master
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:
# make a lot of files, add, commit and so on..
# REMOTE GIT REPO AVAILABLE AT email@example.com:sys/path/remoterepo.git
# First push files to remote repo
git push --remote firstname.lastname@example.org:sys/path/remoterepo.git
# clone the remote repo into a new folder
git clone email@example.com:sys/path/remoterepo.git folder2/
mv folder/ folder-old/
mv folder2/ folder/
# Test, everything ok? If so:
rm -rf folder-old/