git tips

Thursday, December 25th, 2008 | english, utilities

Git is becoming my main utility for Debian packaging, as I am using it to keep my work on packages I maintain alone or in a team by using git.debian.org facilities. I am not still using tools like TopGit to keep patches, by I also intend to do so in a near future.

What does git give me over svn? Basically two things: branches and having the whole source code at hand. The first is obvious, I can easily create branches to experiment without having to change anything in the way the package is, so if a new upstream release occurs in the time it takes me to implement some change (and that usually happens) I can upload it straight, not affecting my undergoing changes.

Also I appreciate having the whole source code. This could have been also done using svn, but we preferred not to do so, and most packages only have debian dir in their svn repositories. This makes harder work with upstream sources, where they need to be patched. Git provides me the way to have always an upstream source code copy at hand, and the branch power can also be applied to it.

But I wanted to write about a couple of git tips that I found. Seems that they have already appeared on Planet Debian before, but I think that is not a bad idea to remember them (from damog’s blog):

1. Changing into a directory that contains a repo and shows you on PS1 what branch you are standing on:

On .bashrc I have:

GITPS1='$(__git_ps1 ":%s ")'

export PS1=”${GREEN}\w${RS} ${YELLOW}${GITPS1}${RS}\\$ ”

But what I didn’t want to lose was the code that was posted to paste.bin after in a comment someone pointed out that this trick was a bit annoying if your home dir were also a git repo. This is one solution:

__maybe_git_ps1 () {

local BRANCH=”$(__git_ps1 ‘%s’)”

case “$BRANCH” in

master)

# silent

;;

”)

# not a git repo? -> silent

;;

*)

if [ -n "$1" ]; then

printf “$1″ “$BRANCH”

else

printf ” (%s)” “$BRANCH”

fi

;;

esac

}

2. An alias I like to use on repos that are personal for quick tracking:

[alias]

log1 = log –pretty=oneline –abbrev-commit

Thanks damog for these tips!

Tags: , , , , , ,

4 Comments to git tips

Np237
December 25, 2008

Putting the whole source code in the VCS makes it completely awkward to update the package using “apt-get source”, since all changes to the upstream source are merged in a single big diff.

The way most packaging subprojects use SVN is merely as a versioned data store. The source changes are managed by quilt, which makes it much easier to deal with the package outside of the repository.

jsogo
December 25, 2008

I was not meaning that. If you see every package I have, patches are always in debian/patch (dpatch format). I have even talked about topgit, which is a tool to make using git and quilt easy.
Of course patching directly upstream source is not a good idea, and should be discouraged. But having the whole source available in the dir you’re working makes things easier.

Np237
December 25, 2008

You can have the whole source without versioning it. When I want another version, I just edit the changelog, run “debian/rules get-orig-source”, and I can start working on my quilt series in a temporary directory.

jsogo
December 26, 2008

Well, this is another option. Having get-orig-source is doable, as you say, but using git is also interesting here. You don’t lose the ability of use quilt and if you’re concerned about keeping upstream tarball as it was got from upstream, you can use pristine-tar.
But of course every option is good as far as you are comfortable with it.

Meta

Search



Free web hostingWeb hosting