This are my notes in the fields of computer science and technology. Everything is written with ABSOLUTE NO WARRANTY of fitness for any purpose. Of course, feel free to comment anything.

Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Tuesday, August 11, 2009

git: write a single commit to file

Write the commit to file:
git diff-tree <commit> -p --pretty > <filename>
You can also use git format-patch, but that is more specialized for patches to be submitted by email.

Apply the commit from the file:
git apply <filename>
Here is an excerpt from the git diff-tree manual page:
When "git-diff-index", "git-diff-tree", or "git-diff-files"
are run with a -p option, "git diff" without the --raw option,
or "git log" with the "-p" option, they do not produce the output
described above; instead they produce a patch file. You can
customize the creation of such patches via the GIT_EXTERNAL_DIFF
and the GIT_DIFF_OPTS environment variables

Sunday, August 9, 2009

GIT_PAGER and LESS colors

I was wondering why, working on two different machines, I was able to display git-log and git-diff colors on one machine and not on the other, despite the same git configuration file ~/.gitconfig:

[color]
diff = auto
status = auto
branch = auto
log = auto

and no particular settings regarding colors in <repository>/.git/config

Although I was not using a Mac, the solution was in this blog post: that is, setting the GIT_PAGER variable to cat was already solving the problem; GIT_PAGER sets which program should be used by git to display for example the diff and log output (default less).

The actual problem was in less and how it outputs ANSI color ESC codes. A solution, similarly to what suggested in that post, was to set the LESS variable to -R and leave GIT_PAGER unset, as it originally was. Regarding the other options suggested in the blog post for LESS, -X and -e have no influence on color display, and -R is probably better than -r; in particular, this in an extract of the less manual, at the -r/-R section, explaining why:
-r or --raw-control-chars

Causes "raw" control characters to be displayed.
[...] Warning: when the -r option is used, less cannot
keep track of the actual appearance of the screen
(since this depends on how the screen responds to
each type of control character). Thus, various display
problems may result, such as long lines being split
in the wrong place.

-R or --RAW-CONTROL-CHARS

Like -r, but only ANSI "color" escape sequences are
output in "raw" form. Unlike -r, the screen appearance
is maintained correctly in most cases. [...]

Saturday, April 11, 2009

capistrano using git

The cap deploy:update task when you are using git runs the following git command: 

git checkout -q -b deploy 3fe75somehash.....

meaning : 

- creates a new branch named "deploy" (what happens if there is already one called like that?)
- the source of the branch is the commit identified by the given hash
- -q option is "quiet mode"

About Me

My photo
Hamburg, Hamburg, Germany
Former molecular biologist and web developer (Rails) and currently research scientist in bioinformatics.