How to Create a New and Empty Branch in Git

git checkout --orphan NEWBRANCH
git rm -rf .
touch .gitignore
git commit -a -m ""

Via bitflop.

Addendum: 2014-02-28:

Create an orhan branch
git checkout --orphan lp
git rm -rf .
touch .gitignore
git add .gitignore
git diff --cached
git commit -m "Initial import."
Create a remote branch
git push -u origin lp
Obtain a remote branch
git checkout -b lp
Delete a branch
Remote: git push origin :lp
Local: git branch -D lp

Pro Git Book Review

As a Subversion master-user I was hoping for a lot from \_Pro Git and was rewarded greatly. The author gives Git a fair shake without throwing Subversion under the bus. He does a great job teaching not just the tools, but the culture and “how to think” the Git way. The latter is devoid in literally every tutorial I’ve seen online, and I’m not sure it is even possible to sum it up in anything less than the entirety of this book. The length is just fine, chapter are brief, terse, light, and information packed. The multitude of tools and approaches revealed in the book make it worth reading, and buying, too. Although the book is free online, the author should be rewarded with a purchase. Before reading this I spent 5 months using Git with the typical docs: man pages,, and random posts. This book pulled everything together, it was kind of like sitting with a hacker who really groks it all (as you will see in the last chapter), and that alone is priceless. 5/5

Addendum: the formatting and graphics in the Kindle version look excellent (forgot to mention this key point as not all Kindle books look this great).

What every Subversion user must know about Git

Subversion is perfect (simple concept, lots of books, good tool integration, and easy to use) but for the fact that it doesn’t support:

While the former should be addressed in version 1.5, the latter is anyone’s guess.

The problem is that Subversion is just so good that eventually you will will want a distributed mode with Subversion.

Fortunately, Git supports distributed operation against Subversion repositories!

If this gets you “on the Git bus”, check out this:

An introduction to git-svn for Subversion/SVK users and deserters.

(Thanks Geoff for the links)

Addendum 05/03/08:

Tonight I tested out setting up cygwin from scratch to use Git, and in doing so confirmed what I knew and discovered what I didn’t!

You must use the following packages:

  1. Git
  2. Subversion 1.4.5-2
  3. Subversion-perl 1.4.5-2

Failure to install the subversion-perl bindings results in the error: = Can’t locate SVN/ in @INC

Thank you ycdtosa for the pointer!

Addendum 05/03/08:

If, like many of us, you haven’t fully cut over to cygwin, you may receive the following error message when you attempt a commit:

You have some suspicious patch lines=

Here is both an explanation of and a work-around for the error.

To solve the problem, you need to edit .git/hooks/pre-commit and comment out the following lines:

=if ($) { bad_line(“trailing whitespace”, $_); }=

Before tonight, I figured that I would never have the need to use dos2unix ever again! Based on one of the commentors replies, though, I expect that further research on the operation of Git is required on my part in order work between CR and CRLF environments:

Git from some time has core.autocrlf and crlf attribute, which should help in mixed UNIX (LF) and Windows (CR LF) environment