Monthly Archives: October 2012

What I learned: How to pull remote branches in Git vs. How to pull remote branches in Mercurial

At work, I use Mercurial. At home, I use Git. Both are distributed source control systems, and both are systems I hadn’t yet used till this year. (A previous job had me working with Perforce, while I was still muddling through Subversion and CVS before that.)

I got familiar with Mercurial before I did any extensive work with Git, so I approached Git with the mindset of “How is this done in Mercurial?” That works for some functions better than others.

Take the notion of pulling remote branches. In Mercurial, you do this:

hg pull -b <remote-branch-name> <repo-name>

This command will create that new branch in your clone of that repository. Git has a similar command:

git fetch origin <remote-branch-name>

This command retrieves information about a remote branch, but it won’t create that branch in your clone. Rather, the new branch needs to be created in the clone first before remote changes are pulled in.

git checkout -b <remote-branch-name>
git pull origin <remote-branch-name>

I could be wrong about that, but so far, it’s been working for me.

UPDATE, 9/29/2014, 12:33: While git pull might work, it’s actually a somewhat redundant step. git pull is really a combination of git fetch and git merge FETCH_HEAD. So if I were to spell out all the commands in this example, it would look something like the following:

git fetch origin <remote-branch-name>
git checkout -b <remote-branch-name>
git fetch origin <remote-branch-name>
git merge FETCH_HEAD

In essence, we’ve called git fetch twice. The net effect is the same. It’s just not … as correct as it should be. So what should really happen is …

git fetch origin <branch-name> --tags
git checkout -b <branch-name>
git merge FETCH_HEAD

… or …

git checkout -b <branch-name>
git pull origin <branch-name> --tags

How to delete a URL from the address bar in Chrome so that it stays deleted

Do a search on how to remove a URL from the Chrome address bar, and you’ll find a lot of confused Firefox users who follow the instructions of experienced Chrome users and get nowhere.

In Firefox, deleting a URL from the address bar is actually a very simple task — highlight the address, press delete (or SHIFT+DEL on a Mac.)

In Chrome, it’s pretty much the same in abstract. But in detail? The experiences are vastly different.

That’s because in Chrome, the address bar isn’t just an address bar — it’s a search interface as well. And the result you see isn’t just an address history … it’s a whole bunch of other stuff, including shortcuts, search results and addresses.

Search results can’t be deleted, and sometimes, those results look exactly the same as your address history. So the Chrome user experience designers have to devise ways to distinguish what you can remove from what you are removing.

(Search results have a magnifying glass icon next to them. You want to delete addresses with the page icon next to them.)

In Firefox, the experience was direct and immediate — type in an address, highlight the address with your mouse, press delete, and the address disappears. You didn’t even need to finish typing the address — if Firefox found a match, it would highlight it for you.

Where Chrome differs is the highlighting — you cannot delete an address in your history if it’s partially highlighted. You must finish typing the complete address before you can highlight it. After it’s highlighted, you may delete it — but don’t expect it to disappear from your interface!

The only indication that an address has been deleted from the address bar history is the removal of the title text next to the highlighted address. If that title text does not disappear, the address was not deleted. To confirm the address has been removed, type it in again — it should no longer appear as a drop-down option.

One thing Chrome makes consistent is the deletion keystroke — it’s SHIFT+DEL on either Windows or Mac.

 These subtleties make deleting a URL from the Chrome address bar much more of a chore than in Firefox, but it is possible.