Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To stage changes[file modifications and deletions].Accepts arguments for files or directories within the project directory. 

$ git add

Options:

$ git add [options]

  • -n  , --dry-run :Don’t actually add the file(s), just show if they exist and/or will be ignored.
  • -v , --verbose :Be verbose.
  • -f , --force      :Allow adding otherwise ignored files.
  • -i , --interactive : Add modified contents in the working tree interactively to the index. Optional path arguments may be supplied to limit operation to a subset of the working tree.
  • -p , --patch   : Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index.
  • -e , --edit  :Open the diff vs. the index in an editor and let the user edit it. After the editor was closed, adjust the hunk headers and apply the patch to the index.
  • -u ,–update :Update the index just where it already has an entry matching <pathspec>. This removes as well as modifies index entries to match the working tree, but adds no new files.

Examples:

Adds content from all *.txt files under Documentation directory and its subdirectories.

$ git add Documentation/\*.txt


commit

Consists of a snapshot of the directory structure and file contents for the entire project.

$ git commit

branch

To view a list of existing branches

$ git branch

Creates a new topic branch

$ git branch [branch]

merge

Merges [branch] into current branch.

$ git merge [branch]

diff

Shows diff of the unstaged changes.

$ git diff

Shows diff of the staged changes.

$ git diff --cached

log

Shows the history of the current branch.

$ git log

Shows the commits that aren't pushed.

$ git log m/[codeline]..