1. How to run same GIT command for all projects in your repository?
[command] repo forall -c "git COMMAND [OPTION] [PARAMETERS]
[for example] repo forall -c "git reset --hard HEAD"
[options list] $ repo forall --help
Usage: repo forall [<project>...] -c <command> [<arg>...]
repo forall -r str1 [str2] ... -c <command> [<arg>...]"
Options:
-h, --help show this help message and exit
-r, --regex Execute the command only on projects matching regex or
wildcard expression
-c, --command Command (and arguments) to execute
-e, --abort-on-errors
Abort if a command exits unsuccessfully
Output:
-p Show project headers before output
-v, --verbose Show command error messages
If you merge for a single project, you can use:
[command] git merge --no-ff TAG_NAME
If you merge for all projects in your repository, use:
[command] repo forall -c "git merge --no-ff TAG_NAME"
3. How to make a patch file?
[command] git format-patch COMMIT_ID -1
[for example] git format-patch ddba7dec11b85e5477ea33a9f81abc957be61a61 -1
[options list] $ git format-patch -h
usage: git format-patch [options] [<since> | <revision range>]
-n, --numbered use [PATCH n/m] even with a single patch
-N, --no-numbered use [PATCH] even with multiple patches
-s, --signoff add Signed-off-by:
--stdout print patches to standard out
--cover-letter generate a cover letter
--numbered-files use simple number sequence for output file names
--suffix <sfx> use <sfx> instead of '.patch'
--start-number <n> start numbering patches at <n> instead of 1
--subject-prefix <prefix>
Use [<prefix>] instead of [PATCH]
-o, --output-directory <dir>
store resulting files in <dir>
-k, --keep-subject don't strip/add [PATCH]
--no-binary don't output binary diffs
--ignore-if-in-upstream
don't include a patch matching a commit upstream
-p, --no-stat show patch format instead of default (patch + stat)
Messaging
--add-header <header>
add email header
--to <email> add To: header
--cc <email> add Cc: header
--in-reply-to <message-id>
make first mail a reply to <message-id>
--attach[=<boundary>]
attach the patch
--inline[=<boundary>]
inline the patch
--thread[=<style>] enable message threading, styles: shallow, deep
--signature <signature>
add a signature
--quiet don't print the patch filenames
[command] patch -p[n] < XXX.patch
[for example] patch -p1 < a.patch
[options list] $ patch --help
Usage: patch [OPTION]... [ORIGFILE [PATCHFILE]]
Input options:
-p NUM --strip=NUM Strip NUM leading components from file names.
-F LINES --fuzz LINES Set the fuzz factor to LINES for inexact matching.
-l --ignore-whitespace Ignore white space changes between patch and input.
-c --context Interpret the patch as a context difference.
-e --ed Interpret the patch as an ed script.
-n --normal Interpret the patch as a normal difference.
-u --unified Interpret the patch as a unified difference.
-N --forward Ignore patches that appear to be reversed or already applied.
-R --reverse Assume patches were created with old and new files swapped.
-i PATCHFILE --input=PATCHFILE Read patch from PATCHFILE instead of stdin.
Output options:
-o FILE --output=FILE Output patched files to FILE.
-r FILE --reject-file=FILE Output rejects to FILE.
-D NAME --ifdef=NAME Make merged if-then-else output using NAME.
-m --merge Merge using conflict markers instead of creating reject files.
-E --remove-empty-files Remove output files that are empty after patching.
-Z --set-utc Set times of patched files, assuming diff uses UTC (GMT).
-T --set-time Likewise, assuming local time.
--quoting-style=WORD output file names using quoting style WORD.
Valid WORDs are: literal, shell, shell-always, c, escape.
Default is taken from QUOTING_STYLE env variable, or 'shell' if unset.
Backup and version control options:
-b --backup Back up the original contents of each file.
--backup-if-mismatch Back up if the patch does not match exactly.
--no-backup-if-mismatch Back up mismatches only if otherwise requested.
-V STYLE --version-control=STYLE Use STYLE version control.
STYLE is either 'simple', 'numbered', or 'existing'.
-B PREFIX --prefix=PREFIX Prepend PREFIX to backup file names.
-Y PREFIX --basename-prefix=PREFIX Prepend PREFIX to backup file basenames.
-z SUFFIX --suffix=SUFFIX Append SUFFIX to backup file names.
-g NUM --get=NUM Get files from RCS etc. if positive; ask if negative.
Miscellaneous options:
-t --batch Ask no questions; skip bad-Prereq patches; assume reversed.
-f --force Like -t, but ignore bad-Prereq patches, and assume unreversed.
-s --quiet --silent Work silently unless an error occurs.
--verbose Output extra information about the work being done.
--dry-run Do not actually change any files; just print what would happen.
--posix Conform to the POSIX standard.
-d DIR --directory=DIR Change the working directory to DIR first.
--reject-format=FORMAT Create 'context' or 'unified' rejects.
--binary Read and write data in binary mode.
-v --version Output version info.
--help Output this help.
Report bugs to <bug-patch@gnu.org>.
5. How to show the tracked files status?
[command] git status --untracked-files=no
Here are the options of git status:
[options list] $ git status -h
usage: git status [options] [--] <filepattern>...
-v, --verbose be verbose
-s, --short show status concisely
-b, --branch show branch information
--porcelain machine-readable output
-z, --null terminate entries with NUL
-u, --untracked-files[=<mode>]
show untracked files, optional modes: all, normal, no. (Default: all)
--ignored show ignored files
--ignore-submodules[=<when>]
ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)
git revert COMMIT_ID
git push aosp HEAD:refs/heads/TAG-NAME
7. How to remove untracked files?
[command] git clean -df
The option list is:
[option list] $ git clean -h
usage: git clean [-d] [-f] [-n] [-q] [-e <pattern>] [-x | -X] [--] <paths>...
-q, --quiet do not print names of files removed
-n, --dry-run dry run
-f, --force force
-d remove whole directories
-e, --exclude <pattern>
add <pattern> to ignore rules
-x remove ignored files, too
-X remove only ignored files
8. If you don't want your modification in your project any more, and you want to restore your project as before you added your modification. You can remove your untracked files use no.7 first, then reset the tracked files use this command:
[command] git reset --hard HEAD
The option list of git reset is:
[option list] $ git reset -h
usage: git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]
or: git reset [-q] <commit> [--] <paths>...
or: git reset --patch [<commit>] [--] [<paths>...]
-q, --quiet be quiet, only report errors
--mixed reset HEAD and index
--soft reset only HEAD
--hard reset HEAD, index and working tree
--merge reset HEAD, index and working tree
--keep reset HEAD but keep local changes
-p, --patch select hunks interactively