Git Recipes
Traduction: [ Google | Babelfish ]
Catégories : [ Informatique/Git ]
Here are a few recipes I use with git.
Using git log
Show which files have been modified by the commits: git log
--name-status
View the successive changes for a given file: git log -p -- my_file
(latest change first)
View the changes at word-level instead of line-level: git log
--color-words
Make --color-words
more readable with LaTeX files: add *.tex diff=tex
to the repository's .git/info/attributes
or to your $HOME/.gitattributes
(read man gitattributes
for more info on this, it supports other languages
too)
Browseable Web Repository
To make an online, browsable web repository on a web server (I assume you have ssh access to it).
On the server, run:$ mkdir some_directory $ cd some_directory $ git init $ git config receive.denyCurrentBranch ignore $ cat > .git/hooks/post-receive <<EOF #!/bin/sh GIT_WORK_TREE=.. git checkout -f GIT_WORK_TREE=.. git update-server-info --force EOF $ chmod a+x .git/hooks/post-receiveThe in the source repository, run:
$ git remote add web username@my.web.server:path/to/some_directory/.git $ git push web master
(“username”, “my.web.server” and “path/to/” are exactly what you think
they are.) Note the “.git” at the end of the path, it has to be there
because git push
is going to send its data into that directory.
When you run git push web master
to upload the content of the source
repository to the web repository, the post-receive
hook checks out the
latest version. The next time, you don't need to specify the “master” branch
any more, simply running git push web
is enough.