git

Referencing the git tracking branch

Why something similar to this isn’t a built-in git command is beyond me. Here’s a handy alias to add to your .gitconfig. It simply prints the currently tracked branch to the screen.

Using origin/master with git-svn

If you have lots of aliases in your ~/.gitconfig referencing origin/master, it can be quite annoying that git-svn provides only a remotes/trunk reference.

To fix this, from the top-level directory of your working copy:

cd .git/refs/remotes
cat trunk   # notice that trunk is just a plain file containing the hash reference of a certain commit
mkdir origin
ln -s ../trunk origin/master   # create a symbolic link from origin/master to trunk

Tadaa, that's it. You can now reference origin/master and it will always stay up-to-date with whatever trunk is referencing!

Strange git rebase --continue failure

$ git pull

CONFLICT (rename/modify): Merge conflict in somefile.txt
Failed to merge in the changes.
Patch failed at 0002 Some commit.

When you have resolved this problem run "git rebase —continue".
If you would prefer to skip this patch, instead run "git rebase —skip".
To restore the original branch and stop rebasing run "git rebase —abort".

…this was an expected conflict, so I resolve it and add the file:

$ git add somefile.txt

Now, to finish up:


$ git rebase —continue
You must edit all merge conflicts and then

Pushing to a remote git working copy

In the case where the remote working copy is the document root of your site and no one is ever making changes there, it's extremely annoying that git provides no flag to the push command to allow you to update the work tree as opposed to only the index.

Enter the post-update hook.

  • download the post-update hook
  • in the remote working copy (which you don't intend to actually work in), place the post-update file in $working_copy/.git/hooks
  • make it executable

Voila. The working copy now actually updates when you push to it.

Getting a functioning Egit plugin

  • Download Eclipse for PHP Developers, version 3.5.1 (Galileo)
  • Go to Java > Installed JREs and make sure a version 1.5.0_11 or later is available (it doesn't have to be the checked one)
  • Install the egit plugin
    • Go to Preferences -> Install/Update -> Available Software Sites and add:

    • Go to Help -> Install New Software, select JGit, and check Eclipe Git Plugin
    • Continue through prompts to finish installation
  • Clone or create a git repository inside your workspace using your favorite tool
Syndicate content