Newbie Query
Hello All,
I am having a go at using git and need a bit of help.
I have git installed on my laptop and on my pc. I created some files on the pc then used git close via ssh to put them on my laptop - all OK so far!
I then modified the files, added them, commited the changes and then used git push to put them on the PC - still no problems.
Both systems show the commits but the PC does not have the latest version of the files. Git status on the PC shows the file as changed but commiting give an error when pushing from the laptop.
I assume that I need to run a command on the PC to get both systems the same. Is it a reset or something else?
Regards,
Chris
Signature · 4 lines
... "Even the gods did not spring into being overnight." Spock -- This message was scanned by ESVA and is believed to be clean.
2009/1/20 Chris Willard <[email protected]>:
Quoted 11 lines
Hello All,
I then modified the files, added them, commited the changes and then used git push to put them on the PC - still no problems.
Both systems show the commits but the PC does not have the latest version of the files. Git status on the PC shows the file as changed but commiting give an error when pushing from the laptop.
I assume that I need to run a command on the PC to get both systems the same. Is it a reset or something else?
So IIUC running 'git log' on the machine you pushed the changes to, you can see the checkin you made on the machine you made the change on? You need to run 'git checkout' on the machine you pushed to, to tell git that you want these files. This is a safety feature, since someone may be working on the files on that machine locally, and so doesn't want them being overwritten by your push.
You may find the documentation (http://git-scm.com/documentation)
useful, especially
http://www.kernel.org/pub/software/scm/git/docs/everyday.html which has your scenario under "Push into another repository. ".
If you want someone to take some changes you made, it is recommended to let them know so that they can run 'git pull' or 'git fetch' to get your changes (performing a merge or rebase as desired). This means that they control when they get the updates and what they want to do with them.
If you are committing the files to a shared public repository (e.g. a central repository, or build server repository), a pussible approach is to create that as a "bare" repository (one with just the contents of the .git folder - i.e. it does not have any files checked out). You can do this by running:
git clone --bare source/git/path/project project.git
you can then clone from this:
git clone my/shared/project.git
and push any changes to it as normal.
The build server can then do a 'git pull' to get the new changes from that repository.
You can keep it setup like you currently have (assuming that where you are pushing to is a shared repository), and do:
git checkout HEAD
before you run a build (assuming this is the repository that you are using for your builds). The advantage of a bare repository is that it will take up less space, and using a different (cloned) repository for performing builds keeps the main repository clean.
One of the great things about git is that you can customise it to fit different workflows.
HTH,
- Reece
Quoted 6 lines · Reece Dunn
If you are committing the files to a shared public repository (e.g. a central repository, or build server repository), a pussible approach is to create that as a "bare" repository (one with just the contents of the .git folder - i.e. it does not have any files checked out). You can do this by running:
Quoted 6 lines
git clone --bare source/git/path/project project.gityou can then clone from this:
git clone my/shared/project.git
and push any changes to it as normal.
Hi,
I did the rookie mistkae on the central server to create the main reposity in non-bare mode. So i need to checkout the HEAD revision each time I push.
Is there a cleaner way to convert a non-bare git repo into a bare repo than cloning it?
My repo have a lot of remote branch registered, and cloning them to a new bare repo mean I'll have to add all those remote branches again (except if there is another trick here I don't know about).
Regards
Nicolas
Quoted 8 lines · On Tuesday 2009 January 20 15:07:55 Nicolas Morey-Chaisemartin wrote:
I did the rookie mistkae on the central server to create the main reposity in non-bare mode. So i need to checkout the HEAD revision each time I push.
Is there a cleaner way to convert a non-bare git repo into a bare repo than cloning it?
My repo have a lot of remote branch registered, and cloning them to a new bare repo mean I'll have to add all those remote branches again (except if there is another trick here I don't know about).
Well, if you can make sure no one is pushing into the repo for a bit: clone it and replace the original with a symlink to new, bare one. Your clients will be able to use the same URL, so they should be happy. (I haven't tried this, but it should work.)
Signature · 4 lines
Boyd Stephen Smith Jr. ,= ,-_-. =. [email protected] ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/
Quoted 12 lines · Boyd Stephen Smith Jr.
Quoted 9 lines · On Tuesday 2009 January 20 15:07:55 Nicolas Morey-Chaisemartin wrote:
I did the rookie mistkae on the central server to create the main reposity in non-bare mode. So i need to checkout the HEAD revision each time I push.
Is there a cleaner way to convert a non-bare git repo into a bare repo than cloning it?
My repo have a lot of remote branch registered, and cloning them to a new bare repo mean I'll have to add all those remote branches again (except if there is another trick here I don't know about).
Quoted 5 lines
Well, if you can make sure no one is pushing into the repo for a bit: clone it and replace the original with a symlink to new, bare one. Your clients will be able to use the same URL, so they should be happy. (I haven't tried this, but it should work.)
Well I know there are solutions to convert it to a bare repo. I was just wondering if there was a "clean" one which really converts the repo to a bare one and not create a copy which is bare. I don't know how bare/non-bare is managed but I guess both types of repo are not differing by much, so it'd be great to have a function to convert from one to another.
Quoted 6 lines · On Tuesday 2009 January 20 15:46:47 Nicolas Morey-Chaisemartin wrote:
Quoted 5 lines · Boyd Stephen Smith Jr.
Quoted 4 lines · On Tuesday 2009 January 20 15:07:55 Nicolas Morey-Chaisemartin wrote:
I did the rookie mistkae on the central server to create the main reposity in non-bare mode.
Is there a cleaner way to convert a non-bare git repo into a bare repo than cloning it?
No.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
My repo have a lot of remote branch registered, and cloning them to a new bare repo mean I'll have to add all those remote branches again (except if there is another trick here I don't know about).
Quoted 8 lines
Quoted 4 lines
Well, if you can make sure no one is pushing into the repo for a bit:
clone it and replace the original with a symlink to new, bare one. Your clients will be able to use the same URL, so they should be happy. (I haven't tried this, but it should work.)Well I know there are solutions to convert it to a bare repo. I was just wondering if there was a "clean" one which really converts the repo to a bare one and not create a copy which is bare.
The clone *is* a way to convert, with the added advantage of not trashing the original during the conversion, by putting the results in a different location. In fact, it's probably *cleaner* than any convert-in-place.
Quoted 3 lines
I don't know how bare/non-bare is managed but I guess both types of repo are not differing by much, so it'd be great to have a function to convert from one to another.
I couldn't tell you all the differences, but I don't think there are many either.
Signature · 4 lines
Boyd Stephen Smith Jr. ,= ,-_-. =. [email protected] ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/
Quoted 3 lines · Nicolas Morey-Chaisemartin
Well I know there are solutions to convert it to a bare repo. I was just wondering if there was a "clean" one which really converts the repo to a bare one and not create a copy which is bare.
It has been a long time since I have done this. It used to be that you could simply "mv foo/.git foo.git" and be done with it. These days I think you would also need "git config core.bare true". But I haven't actually tested it recently.
You may also want to tweak other config settings (e.g., bare repositories do not generally have reflogs turned on, but non-bare do).
-Peff
Hi,
Quoted 10 lines · Jeff King
Quoted 3 lines · Nicolas Morey-Chaisemartin
Well I know there are solutions to convert it to a bare repo. I was just wondering if there was a "clean" one which really converts the repo to a bare one and not create a copy which is bare.
It has been a long time since I have done this. It used to be that you could simply "mv foo/.git foo.git" and be done with it. These days I think you would also need "git config core.bare true". But I haven't actually tested it recently.
Yep, you need to set that option. At least if you initialized your repository with anything newer than v1.5.0-rc1~3^2~2.
Ciao,
Dscho
Quoted 11 lines · Chris Willard
Hello All,
I am having a go at using git and need a bit of help.
I have git installed on my laptop and on my pc. I created some files on the pc then used git close via ssh to put them on my laptop - all OK so far!
I then modified the files, added them, commited the changes and then used git push to put them on the PC - still no problems.
Quoted 6 lines
Both systems show the commits but the PC does not have the latest version of the files. Git status on the PC shows the file as changed but commiting give an error when pushing from the laptop.
I assume that I need to run a command on the PC to get both systems the same. Is it a reset or something else?
http://git.or.cz/gitwiki/GitFaq#non-bare
tom
Heya,
Quoted 6 lines · Chris Willard
I then modified the files, added them, commited the changes and then used git push to put them on the PC - still no problems.
Both systems show the commits but the PC does not have the latest version of the files. Git status on the PC shows the file as changed but commiting give an error when pushing from the laptop.
Please read http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73
and let us know if you have any other problems.
Signature · 3 lines
Cheers, Sverre Rabbelier
Quoted 3 lines · Chris Willard
Hello All,
I am having a go at using git and need a bit of help.
[snip]
Thanks for all the tips - I used "git-reset --hard" to solve my problem.
Regards,
Chris
Signature · 7 lines
-----------( "The Batman play seemed important to Crow." -- )------------
-----------( Mike Nelson )------------
Chris -----( )---- Willard
Htag.pl 0.0.23
--
This message was scanned by ESVA and is believed to be clean.