• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/34

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

34 Cards in this Set

  • Front
  • Back
  • 3rd side (hint)
Git command to use when starting to track an existing project in Git
Go to the project's directory:
git init
At this point, nothing is tracked yet. You still need to issue some "git add" commands followed by a commit.
Git command to use when getting a copy of an existing Git repository
git clone <url> [optional-directory-name]
4 states of files
untracked
unmodified
modified
staged
Git command to determine which files are in which state, and which branch you're on
git status
Git command to use when beginning tracking a new file or directory
git add <file-pattern>...
if it's a directory, all the files in that directory are added recursively.
Git command to use when staging modified files
git add <file-pattern>...
if you modify a file after "git add", you have to run "git add" again to stage the latest version.
How to ignore some files
create .gitignore file:
*.[oa]
*~
*.log
Rules for the patterns to use in .gitignore file
* Blank lines or lines starting with # are ignored
* Standard glob patterns work
* You can end patterns with a / to specify a directory
* You can negate a pattern by starting it with an !
Glob patterns:
* to match zero or more characters
[abc] matches any character inside the brackets
? matches a single character
[0-9] matches any characters in the range
Git command to show exact changes in files you've changed but not yet staged
git diff
Git command to see what you've staged that will go into your next commit
git diff --staged
or
git diff --cached (before git 1.6.1)
Commit changes and type commit comment using default text editor
git commit
Commit changes with diff of your chnage displayed in the default editor for commit message
git commit -v
Commit changes with inline commit message
git commit -m <msg>
Option of "git commit" command to make Git automatically stage every file that is already tracked before doing the commit
git commit -a
Git command to remove a file from Git
git rm <file>...
it also removes the file from your working directory.
You can pass files, directories, and file-glob patterns, but need to use backslash (\) in front of * to shell-escape them.
Git command to remove a file that's already modified and staged
git rm -f <file>...
Git command to keep a file in your working tree but no longer want it to be tracked by Git
git rm --cached <file>...
Git command to rename a file
git mv <source> <destination>
equivalent to:
mv <source> <destination>
git rm <source>
git add <destination>
Git command to view commit history
git log
Option of "git log" to show the diff introduced in each commit
git log -p
Option of "git log" to show some abbreviated stats for each commit
git log --stat
Option of "git log" to change the log output to formats other than the default
git log --pretty=<format>
Formats of "git log"
oneline, short, full, fuller, or custom format:
git log --pretty=format:"%h - %an, %ar : %s"
Some format options:
%H Commit hash
%h Abbreviated commit hash
%T Tree hash
%t Abbreviated tree hash
%P Parent hashes
%p Abbreviated parent hashes
%an Author name
%ae Author e-mail
%ad Author date (respecting -date= option)
%ar Author date, relative
%cn Committer name
%ce Committer e-mail
%cd Committer date
%cr Committer date, relative
%s Subject
Option of "git log" to add a nice little ASCII graph showing your branch and merge history
git log --graph
Works well with --pretty=oneline or custom format --pretty=format:"%h %s"
Option of "git log" to display only the changed/insertions/deletions line of the statistics
git log --shortstat
Limiting "git log" output to show the last <n> commits
git log -<n>
Time-limiting options of "git log"
git log --since=2.weeks
git log --after=1.month
git log --until="2008-01-15"
git log --before="2 years 1 day 3 minutes"
Option of "git log" to filter on a specific author or committer
git log --author=<author>
git log --committer=<committer>
Option of "git log" to search for keywords in the commit messages.
git log --grep=<pattern>
Option of "git log" to "AND" all filters
git log --author=<author> --grep=<pattern> --all-match
Make "git log" to limit the output to commits that introduced a change to a file
git log <filepattern>
Always the last option, and is generally preceded by double dashes (- -)
Git command to amend a commit
git commit --amend
If no changes since last commit have been made, all you'll change is your commit message.
To unstage a staged file (back to modified status)
git reset HEAD <file>...
To unmodify (revert) a modified file
git checkout -- <file>...
Warning: the change is lost forever because it's never committed.