Saltycrane logo

SaltyCrane Blog

Notes on Python, Django, and web development on Ubuntu Linux

    

git notes

How to get the tag associated with a specific git revision

$ git describe --tags 5c70d1a15a4637a2057b1464c54820629e78cd05
staging/1.5

How to show the tracked branches from the remote "origin"

$ git remote show origin 

How to find renames

$ git log --name-only --follow --all -- filename 

How to remove all local tags

From http://stackoverflow.com/questions/1841341/remove-local-tags-that-are-no-longer-on-the-remote-repository/5373319#5373319

$ git tag -l | xargs git tag -d 

How to detach a subdirectory into separate Git repository

Note I did not want any tags or branches in the new repository. From http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository/359759#359759

$ git clone --no-hardlinks /XYZ /ABC
$ cd /ABC
$ git remote rm origin
$ git tag -l | xargs git tag -d
$ git filter-branch --subdirectory-filter ABC HEAD
$ git reset --hard
$ rm -rf .git/refs/original/
$ git reflog expire --expire=now --all
$ git gc --aggressive --prune=now 

How to convert a Mercurial repo to git

From http://hedonismbot.wordpress.com/2008/10/16/hg-fast-export-convert-mercurial-repositories-to-git-repositories/

$ git clone git://repo.or.cz/fast-export.git
$ mkdir new_git_repo
$ cd new_git_repo
$ git init
$ /path/to/hg-fast-export.sh -r /path/to/hg_repo
$ git checkout HEAD

Post a comment

Required
Required, but not displayed
Optional

Format using Markdown. (No HTML.)
  • Code blocks: prefix each line by at least 4 spaces or 1 tab (and a blank line before and after)
  • Code span: surround with backticks
  • Blockquotes: prefix lines to be quoted with >
  • Links: <URL>
  • Links w/ description: [description](URL)
Created with Django | Hosted by Linode