You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Provide details about Repo & Git commands

Git Command Referrence

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.

checkout

To switch to another branch in your local work environment.

$ git checkout BRANCH_NAME

add

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.Record changes to the repository.

$ git commit

Options:

  • -a , --all : Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.
  • --p , --patch : Use the interactive patch selection interface to chose which changes to commit. See git-add[1] for details.
  • -C <commit> ,  --reuse-message=<commit> : Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.
  • -c <commit> , --reedit-message=<commit> : Like -C, but with -c the editor is invoked, so that the user can further edit the commit message.
  • --squash=<commit> : Construct a commit message for use with rebase --autosquash
  • --branch : Show the branch and tracking info even in short-format.
  • -F <file> , --file=<file> : Take the commit message from the given file. Use - to read the message from the standard input.

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]..
  • No labels