I have decided to try and work on EGit (the git plugin for eclipse) in my spare time. First I have to grok git and that's proving harder than anticipated.
Now when I say version control I have a couple basic expectations:
- I want it to be easy to get a workspace
- I want it to be easy to publish my changes
So "the get a workspace" is easy with git :
$>git clone @projecturl clone #clone is the destination directory $>cd clone $clone>git branch -a * master origin/HEAD origin/master origin/stable
There you have your workspace.
Now editing master directly is not recommanded. you should make a local branch to work on your modifications and of course checkout this branch
$clone>git branch master work $clone>git checkout work
(note that you can actually create the new branch as part of the checkout by using the -b
Now I want the "publish my changes" part and that's not quite as straightforward ... Heading to the documentation tells me :
$clone>git push @sshurl master:master
but that seems like a lot of typing if I'm going to do it frequently. (not as frequently as commit but still ... Going further down gives me :
$clone>cat >>.git/config << EOF [remote "public-repo"] url = @sshurl fetch = +refs/heads/*:refs/remotes/origin/* EOF
yeah right, this makes the command [irony]soooo much smaller[/irony]
$clone> git push published master
but I am really lazy I want to only have to do "git push" so let's have a look at .git\config :
$clone>cat .git\config [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = @projecturl fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master [remote "public-repo"] url = ssh://yourserver.com/~you/proj.git fetch = +refs/heads/*:refs/remotes/origin/*
Here goes my solution :
$clone>cat >>.git/config << EOF [branch "work"] remote =public-repos merge = refs/heads/master EOF
Now you can just do git push from your "work" branch to your public repository!
[rant]why do I have to update the config file by hand for such an obvious use case ... go figure ![rant]