GitTips
Tips for using Git
git When UsingGit, there are a few tips that are particularly useful when working on the Chromium codebase, especially due to its size. See also GitCookbook. Remember the basic git convention: git COMMAND [FLAGS] [ARGUMENTS]Various git commands have underlying executable with a hyphenated name, such as git-grep, but these can also be called via the git wrapper script as git grep (and man should work either way too). Git referencesThe following resources can provide background on how Git works:
SearchingUse git-grep instead of grep and git-ls-files instead of find, as these search only files in the index or tracked files in the work tree, rather than all files in the work tree. Note that git-ls-files is rather simpler than find, so you'll often need to use xargs instead of -exec if you want to process matching files. Global changesTo make global changes across the source tree, it's often easiest to use sed with git-ls-files. Remember that you don't need to use xargs, since sed can take multiple input files. E.g., to strip trailing whitespace from C++ and header files: sed -i -E 's/\s+$//' $(git ls-files '*.cpp' '*.h') Diffsgit diff --shortstat Displays summary statistics, such as: 2104 files changed, 9309 insertions(+), 9309 deletions(-) |