RDK Resources
[*RDK Preferred*]
Code Management Facility
RDK Forums
[RDK Conferences]
RDK Support
Archives
Papers & Presentations Archive
Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals. This page familiarizes some of the useful git commands while dealing with RDK code base.
...
$ git checkout BRANCH_NAME |
Synopsis
Code Block |
---|
git checkout [-q] [-f] [-m] [<branch>] |
...
git checkout [-q] [-f] [-m] --detach [<branch>] |
...
git checkout [-q] [-f] [-m] [--detach] <commit> |
...
git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>] |
...
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>… |
...
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] --pathspec-from-file=<file> [--pathspec-file-nul] |
...
git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>…] |
Options
--quiet
is specified.HEAD
. This is used to throw away local changes.<new_branch>
and start it at <start_point>
<new_branch>
and start it at <start_point>
; if it already exists, then reset it to <start_point>
. This is equivalent to running "git branch" with "-f".branch.autoSetupMerge
configuration variable is true....
To stage changes[file modifications and deletions].Accepts arguments for files or directories within the project directory.
$ git add |
Synopsis
Code Block |
---|
git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p] [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] [--intent-to-add | -N] [--refresh] |
...
[--ignore-errors] [--ignore-missing] [–renormalize] [--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]] |
...
[--] [<pathspec>…] |
Options
$ git add [options]
Example
$ git add Documentation/\*.txt file1.c file2.c |
Adds the file1.c and file2.c available in the current folder directoryAdds content from all *.txt
files under Documentation
directory and its subdirectories.
commit
Consists of a snapshot of the directory structure and file contents for the entire project. Record changes to the repository.
$ git commit |
Synopsis
Code Block |
---|
git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [–amend] |
...
[--dry-run] [(-c | -C | --fixup | --squash) <commit>] |
...
[-F <file> | -m <msg>] [--reset-author] [--allow-empty] |
...
[--allow-empty-message] [--no-verify] [-e] [–author=] |
...
[--date=<date>] [--cleanup=<mode>] [--[no-]status] |
...
[-i | -o] [--pathspec-from-file=<file> [--pathspec-file-nul]] |
...
[-S[<keyid>]] [--] [<pathspec>…] |
Options
-c
the editor is invoked, so that the user can further edit the commit message.rebase --autosquash
. Example
$ vim file1.c // edit hellothe file1.c |
The
...
command git
...
commit
...
-
...
a first looks
...
at
...
the working
...
tree,
...
notices that file1.c modified and removed file2.c,
...
performs
...
necessary git
...
add
...
and git
...
rm
...
.
...
...
...
$ git branch
Creates a new topic branch
No Format |
---|
$ git |
...
push |
Synopsis
Code Block |
---|
git |
...
push [-- |
...
all | -- |
...
mirror | --tags] [-- |
...
follow- |
...
tags] |
...
[-- |
...
atomic] [- |
...
n | -- |
...
dry- |
...
run] |
...
[--receive- |
...
pack=<git-receive-pack>] [-- |
...
repo= |
...
<repository>] |
...
[ |
...
- |
...
f | -- |
...
force] [-d | --delete] [-- |
...
prune] [ |
...
Options
--delete --force
.-f
, git branch refuses to change an existing branch.<pattern>...
, e.g. git branch --list 'maint-*'
, list only the branches that match the pattern(s).--list
to match optional pattern(s).Example
...
$ git branch dev
creating a new git branch called “dev”
...
$ git branch -d dev
Deleted branch dev
merge
Merges [branch]
into current branch.
...
$ git merge [branch]
Synopsis
...
-v | --verbose]
[-u | --set-upstream] [-o <string> | --push-option=<string>] [--[no-]signed|--signed=(true|false|if-asked)] [--force-with-lease[=<refname>[:<expect>]] [--no-verify] [<repository> [<refspec>…]] |
Example
$ git push origin HEAD:refs/for/master |
This will push the changes to master branch available in the remote location
$ git branch |
Creates a new topic branch
$ git branch [branch] |
Synopsis
Code Block |
---|
git branch [--color[=<when>] | --no-color] [--show-current] [-v [--abbrev=<length> | --no-abbrev]] [--column[=<options>] | --no-column] [--sort=<key>] [(--merged | --no-merged) [<commit>]] [--contains [<commit]] [--no-contains [<commit>]] [--points-at <object>] [--format=<format>] [(-r | --remotes) | (-a | --all)] [--list] [<pattern>…]
git branch [--track | --no-track] [-f] <branchname> [<start-point>]
git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
git branch --unset-upstream [<branchname>]
git branch (-m | -M) [<oldbranch>] <newbranch>
git branch (-c | -C) [<oldbranch>] <newbranch>
git branch (-d | -D) [-r] <branchname>…
git branch --edit-description [<branchname>] |
Options
--delete --force
.-f
, git branch refuses to change an existing branch.<pattern>...
, e.g. git branch --list 'maint-*'
, list only the branches that match the pattern(s).--list
to match optional pattern(s).Example
$ git branch development |
creating a new git branch called “development”
$ git branch -d development |
Deleted development branch
Options
--no-overwrite-ignore
to abort.Example
...
$ git merge fixes enhancements
Merge branches fixes
and enhancements
on top of the current branch, making an octopus merge.
Show changes between commits, commit and working tree, etc
$ git diff |
Synopsis
Code Block |
---|
git diff [<options>] [<commit>] [--] [<path>…] git diff [<options>] --cached [<commit>] [--] [<path>…] git diff [<options>] <commit> <commit> [--] [<path>…] git diff [<options>] <blob> <blob> git diff [<options>] --no-index [--] <path> <path> |
Options
--patch
. Implies -p
.Example
...
$ git diff - Changes in the working tree not yet staged for the next commit. (1) $ git diff --cached (2) $ git diff HEAD--cached - Changes (3) |
...
Changes in the working tree not yet staged for the next commit.
between the index and the last commit; what would be committing on running "git commit" without "-a" option. $ git diff HEAD - Changes in the working tree since |
...
last commit; what |
...
would be |
...
committing on running "git commit -a" |
log
Show commit logs. Shows the history of the current branch.
...
Example
$
|
Show the whole commit history, but skip any merges
...
$ git rebase [options] |
Synopsis
Code Block |
---|
...
git rebase [-i | --interactive] [<options>] [--exec <cmd>] |
...
[--onto <newbase> | --keep-base] [<upstream> [<branch>]] |
...
git rebase [-i | --interactive] [<options>] [--exec <cmd>] [--onto <newbase>] |
...
--root [<branch>] |
...
git rebase (--continue | --skip | --abort | --quit | --edit-todo | --show-current-patch) |
Options :
git show REBASE_HEAD
....
To squash a series of commits into a single commit.
Stash the changes in a dirty working directory away.when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your command saves the local modifications away and reverts the working directory to match the HEAD
commit.
Synopsis
...
Code Block |
---|
git stash list [<options>] |
...
git stash show [<options>] [<stash>]
|
...
git stash drop [-q|--quiet] [<stash>]
|
...
git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
|
...
git stash branch <branchname> [<stash>]
|
...
git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] |
...
[-u|--include-untracked] [-a|--all] [-m|--message <message>] |
...
|
...
[--] [<pathspec>…]] |
...
git stash clear
|
...
git stash create [<message>]
|
...
git stash store [-m|--message <message>] [-q|--quiet] <commit> |
Options :
stash@{0}
is the latest entry,stash@{1}
is the one before, etc.),<stash>
is given, it removes the latest one. i.e.stash@{0}
, otherwise<stash>
must be a valid stash log reference of the formstash@{<revision>}
.<branchname>
starting from the commit at which the<stash>
was originally created, applies the changes recorded in<stash>
to the new working tree and index. If that succeeds, and<stash>
is a reference of the formstash@{<revision>}
, it then drops the<stash>
. When no<stash>
is given, applies the latest one.Example
$ git pull
...
file foobarfile1.x not up -to -date, cannot merge.
$ git stash
$ git pull
$ git stash pop |
...