Blog posts tagged 'git'

Search git branch names using command line

Dec 15 17

Looking for a particular branch, and git branch -a returns a LOT of branches?
If on Windows, you could use the Search feature in cmder (you’re using cmder, right?)

Or on mac, cmd+f and then search the outputted text…

OR you could use one of these two approaches:

git branch takes a --list argument , which in turn takes a search arg.

git branch -a --list *something*

Will return only the branches containing the word “something” (note the wildcard character)

The alternative, if in bash / bash compatible terminal (git bash / cmder etc… on Windows – normal Command Prompt won’t work – unless you’ve got bash extensions installed) is to pipe the result to grep:

git branch -a | grep something

Both methods here will yield the same results.

Side note:
-a shows all local and remote branches
-r shows only remote branches

Search for a branch with git

Aug 18 16

Got a load of branches?
Need to find a specific one?

Try this

for example

Will return all branches (remote or local) that contain “notifications” in the name of the branch

Github name squatting policy bullshit

Nov 24 14

I’ve been a loyal customer of GitHub since 2010
A couple of years ago, I started Cohoda – a software consulting company.

Shortly after forming the company, I tried to register the github username – ‘cohoda’
It was taken (which I thought odd, since ‘Cohoda’ was a made up word!)

After some investigation, I could see that there was literally nothing on the profile.

  • No name
  • No photo
  • No activity

No google results for “”

I contacted GitHub support, thinking that perhaps I had registered the name previously, but had forgot.

They refuse point blank to help, saying the “username is not available for release under our name-squatting policy”

Their suggestion is to create a new username appended with ‘ltd’ or ‘2’ or something like that.

I wonder what would have happened, should I have registered ‘twitter’ or ‘dropbox’ or ‘google’ in GitHub’s infancy?
Would they have stuck to their ‘name squatting’ policy? I think not.

2015 Update

After contacting them again, and pointing out this is clearly a dormant account, they relinquished the name, and Cohoda LTD are now the proud owners of the Cohoda GitHub username. Finally!

One of the many benefits of keeping a git repository inside dropbox

May 22 14

A couple of weeks ago, for a number of reasons, I had polluted my working copy so much, i decided it would be easier to simply blow my cloned repository folder away, and re-clone.

So, I deleted the folder, and made a fresh checkout to the same place.

Today, I was about to resume work on a feature I’d started; you guessed it, around 2 weeks ago.
It was on a separate branch – a branch, which had been lost when I deleted the folder containing my git checkout.
Naturally, I had not pushed this branch.

Uh oh, I thought.. but not for long.

I use my Dropbox folder as my main folder for nearly all my files on my machine – projects, docs, photos etc…
As I’m sure you know, Dropbox allows you to restore previous version of a file to a previous revision (or undelete)

The only trouble is, you can’t do this on a directory level.

I found this project on github –
This enables you (via the simple command line interface) to restore an entire directory within your dropbox folder to a previous date.

Using this, I was able to roll back my entire folder containing my git repository to a point in time – before I’d deleted it.
Sure, I could have done this with reflog – but that wouldn’t have helped if I hadn’t committed changes!

Once I’d used the script to roll back, my working directory was as it was prior to me deleting it – some files staged, some not!

Git Error – bad config file line 1 in .git/config

Aug 15 13

Last night, just before leaving the office, my development VM decided to crash unexpectedly.
Upon starting the machine the machine the following morning, and trying a git pull, I got the following error:

bad config file line 1 in .git/config

I CD’d into my .git directory, and opened up config in notepad
There was nothing in there, except for a load of whitespaces.
To fix this, I removed the whitespaces and saved the file.
Of course, this had lost my remote settings, but a quick git remote add origin <url> fixed this issue also