forked from schacon/gitbook
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated git log, removed advanced git log, added git hooks beginning,…
… links for corruption recovery, advanced merging beginning, transfer protocols doc
- Loading branch information
Showing
8 changed files
with
371 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Filtering Branches ## | ||
|
||
linkgit:git-filter-branch[1] | ||
|
||
can rewrite history |
54 changes: 53 additions & 1 deletion
54
text/30_Customizing_Git_Git_Config/0_ Customizing_Git_Git_Config.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,55 @@ | ||
## Customizing Git ## | ||
|
||
(interesting or most useful git-config options) | ||
linkgit:git-config[1] | ||
|
||
### Changing your Editor ### | ||
|
||
$ git config --global core.editor emacs | ||
|
||
### Adding Aliases ### | ||
|
||
$ git config --global alias.last 'cat-file commit HEAD' | ||
|
||
$ git last | ||
tree c85fbd1996b8e7e5eda1288b56042c0cdb91836b | ||
parent cdc9a0a28173b6ba4aca00eb34f5aabb39980735 | ||
author Scott Chacon <schacon@gmail.com> 1220473867 -0700 | ||
committer Scott Chacon <schacon@gmail.com> 1220473867 -0700 | ||
|
||
fixed a weird formatting problem | ||
|
||
$ git cat-file commit HEAD | ||
tree c85fbd1996b8e7e5eda1288b56042c0cdb91836b | ||
parent cdc9a0a28173b6ba4aca00eb34f5aabb39980735 | ||
author Scott Chacon <schacon@gmail.com> 1220473867 -0700 | ||
committer Scott Chacon <schacon@gmail.com> 1220473867 -0700 | ||
|
||
fixed a weird formatting problem | ||
|
||
### Adding Color ### | ||
|
||
See all color.* options in the linkgit:git-config[1] docs | ||
|
||
$ git config color.branch auto | ||
$ git config color.diff auto | ||
$ git config color.interactive auto | ||
$ git config color.status auto | ||
|
||
Or, you can set all of them on with the color.ui option: | ||
|
||
$ git config color.ui true | ||
|
||
### Commit Template ### | ||
|
||
$ git config commit.template '/etc/git-commit-template' | ||
|
||
### Log Format ### | ||
|
||
$ git config format.pretty oneline | ||
|
||
|
||
### Other Config Options ### | ||
|
||
There are also a number of interesting options for packing, gc-ing, merging, | ||
remotes, branches, http transport, diffs, paging, whitespace and more. If you | ||
want to tweak these, check out the linkgit:git-config[1] docs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,64 @@ | ||
## Git Hooks ## | ||
|
||
(useful or most interesting git-hooks) | ||
[Git Hooks](http://www.kernel.org/pub/software/scm/git/docs/githooks.html) | ||
|
||
applypatch-msg | ||
### Server Side Hooks ### | ||
|
||
pre-applypatch | ||
#### Post Receive #### | ||
|
||
http://www.kernel.org/pub/software/scm/git/docs/githooks.html | ||
|
||
GIT_DIR/hooks/post-receive | ||
|
||
If you wrote it in Ruby, you might get the args this way: | ||
|
||
ruby | ||
rev_old, rev_new, ref = STDIN.read.split(" ") | ||
|
||
Or in a bash script, something like this would work: | ||
|
||
#!/bin/sh | ||
# <oldrev> <newrev> <refname> | ||
# update a blame tree | ||
while read oldrev newrev ref | ||
do | ||
echo "STARTING [$oldrev $newrev $ref]" | ||
for path in `git diff-tree -r $oldrev..$newrev | awk '{print $6}'` | ||
do | ||
echo "git update-ref refs/blametree/$ref/$path $newrev" | ||
`git update-ref refs/blametree/$ref/$path $newrev` | ||
done | ||
done | ||
|
||
|
||
### Client Side Hooks ### | ||
|
||
|
||
#### Pre Commit #### | ||
|
||
Running your tests automatically before you commit | ||
|
||
GIT_DIR/hooks/pre-commit | ||
|
||
Here is an example of a Ruby script that runs RSpec tests before allowing a commit. | ||
|
||
ruby | ||
html_path = "spec_results.html" | ||
`spec -f h:#{html_path} -f p spec` # run the spec. send progress to screen. save html results to html_path | ||
|
||
# find out how many errors were found | ||
html = open(html_path).read | ||
examples = html.match(/(\d+) examples/)[0].to_i rescue 0 | ||
failures = html.match(/(\d+) failures/)[0].to_i rescue 0 | ||
pending = html.match(/(\d+) pending/)[0].to_i rescue 0 | ||
|
||
if failures.zero? | ||
puts "0 failures! #{examples} run, #{pending} pending" | ||
else | ||
puts "\aDID NOT COMMIT YOUR FILES!" | ||
puts "View spec results at #{File.expand_path(html_path)}" | ||
puts | ||
puts "#{failures} failures! #{examples} run, #{pending} pending" | ||
exit 1 | ||
end | ||
|
||
* http://probablycorey.wordpress.com/2008/03/07/git-hooks-make-me-giddy/ |
3 changes: 3 additions & 0 deletions
3
text/32_Git_Recovery_Corrupted_Objects/0_ Git_Recovery_Corrupted_Objects.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
## Recovering Corrupted Objects ## | ||
|
||
[Recovering Lost Commits Blog Post](http://programblings.com/2008/06/07/the-illustrated-guide-to-recovering-lost-commits-with-git) | ||
|
||
[Recovering Corrupted Blobs by Linus](http://www.kernel.org/pub/software/scm/git/docs/howto/recover-corrupted-blob-object.txt) |
Oops, something went wrong.