Bokken and Sword Training

The guys training with wooden swords (Bokken) and metal swords.

git – delete local tracking branches

(Just a summary of Stack Overflow “How do you Remove an Invalid Remote Branch Reference from Git?”).

To delete a local tracking branch (without deleting the remote branch), do:

git branch -rd remote/branch

And of course to delete the remote branch:

git push remote :branch

Occasionally a gc will help, but usually shouldn’t be used:

git gc --prune=now

So, when would you want to use this? Let’s say the repository you’re tracking has a lot of branches (eg the Linux Kernel). You start tracking branch “foo”, do some work with it, merge some of it in to your branch “bar”, then push “bar” up to the remote repository. Or, you’ve got a whole lot of dev branches you’ve merged pushed to your backup repository and also merged into your master branch.

In either case you’ve got a collection of tracking branches you don’t want to see anymore, so clean them up:

% git branch -r
  soniah/dev.a
  soniah/dev.b
  soniah/dev.c
  soniah/dev.d
  soniah/master

% git branch -rd soniah/dev.a
Deleted remote branch soniah/dev.a (was deadbeef).

% git branch -rd soniah/dev.b
Deleted remote branch soniah/dev.b (was deadbeef).

# now remote branches is cleaner:
% git branch -r
  soniah/dev.c
  soniah/dev.d
  soniah/master

git pull -f (git force pull)

Git has a “force push” option (git push -f remote branch), but it doesn’t have a “force pull” option (like git pull -f remote branch).

This works:

% git fetch remote branch
% git reset --hard FETCH_HEAD
% git clean -df

Or, as a function for your bash/zsh config file:

gpuf () {
   # git pull -f $1
   remote=${1:?"need remote to force pull from"}

   current_branch=$(git symbolic-ref -q HEAD)
   current_branch=${current_branch##refs/heads/}
   current_branch=${current_branch:-HEAD}
   if [ $current_branch = 'HEAD' ] ; then
       echo
       echo "On a detached head. Exiting..."
       exit 1
   fi  

   git fetch $remote $current_branch
   git reset --hard FETCH_HEAD
   git clean -df 
}

Linux filename suffixes

When creating files in Linux (and other OS’s) there’s the usual convention of .txt for text files, .c for C files, etc – you just pick them up as you go along.

But there’s actually a manpage that lists the common conventions – “who knew”?

% man suffixes
SUFFIXES(7)                           Linux Programmer's Manual                           SUFFIXES(7)

NAME
       suffixes - list of file suffixes

DESCRIPTION
       It  is  customary to indicate the contents of a file with the file suffix, which consists of a
       period, followed by one or more letters.  Many standard utilities, such as compilers, use this
...
        .asm         │ (GNU) assembler source file
        .au          │ Audio sound file
        .aux         │ LaTeX auxiliary file
...

Brawl Video – Self Defence Lessons

This brawl video shows some good self defence lessons. Chest pushing -> wild punching -> shirt,hair,standup grappling -> ground grappling ie Muay Thai -> Wrestling -> BJJ. But that you don’t want to get stuck grappling – someone else can then come and punch/kick you in the head…

Lot’s of people were hurt, but imagine if improvised weapons (beer bottles, bricks) had been used – even worse… :-( And like most fights, any of them could have just “counted to 10″ and walked away – always the best approach :-)

« Previous PageNext Page »