Changes between Initial Version and Version 1 of GitCheatSheet


Ignore:
Timestamp:
Dec 8, 2015, 11:34:53 PM (10 years ago)
Author:
nathanm
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GitCheatSheet

    v1 v1  
     1Git Cheat Sheet by Nathan (I definitely didn't copy and paste this from some guy's blog or anything (°¿°)
     2
     3    Configure
     4        git config –global user.name "[name]"
     5            Sets the name you want attached to your commit transactions
     6        git config –global user.email "[email address]"
     7            Sets the email you want attached to your commit transactions
     8        git config –global color.ui auto
     9            Enables helpful colorization of command line output
     10        git config –global push.default current
     11            Update a branch with the same name as current branch if no refspec is given
     12        git config –global core.editor [editor]
     13            Which editor to use when commit and tag that lets you edit messages
     14        git config –global diff.tool [tool]
     15            Specify which command to invoke as the specified tool for git difftool
     16
     17    Create repositories
     18        git init [project-name]
     19            Creates a new local repository with the specified name
     20        git clone [url]
     21            Downloads a project nd its entire version history
     22
     23    Make changes
     24        git status
     25            Lists all new or modified files to be committed
     26        git status -s
     27            Short view of status
     28        git diff
     29            Shows file differences not yet staged
     30        git add [file]
     31            Snapshots the file in preparation for versioning
     32        git add .
     33            Add all modified files to be commited
     34        git add '*.txt'
     35            Add only certain files
     36        git add –patch filename.x (or -p for short)
     37            Snapshot only chunks of a file
     38        git rm [file]
     39            Tell git not to track the file anymore
     40        git diff –staged
     41            Show what has been added to the index via git add but not yet committed
     42        git diff HEAD
     43            Shows what has changed since the last commit.
     44        git diff HEAD^
     45            Shows what has changed since the commit before the latest commit
     46        git diff [branch]
     47            Compare current branch to some other branch
     48        git difftool -d
     49            Same as diff, but opens changes via difftool that you have configured
     50        git difftool -d master..
     51            See only changes made in the current branch
     52        git diff –no-commit-id –name-only –no-merges origin/master…
     53            See only the file names that has changed in current branch
     54        git diff –stat
     55            See statistics on what files have changed and how
     56        git reset [file]
     57            Unstages the file, but preserves its contents
     58        git commit
     59            Record changes to git. Default editor will open for a commit message
     60        git commit -m "[descriptive message]"
     61            Records file snapshots permanently in version history
     62        git commit –amend
     63            Changing the history, of the HEAD commit
     64
     65    Group changes
     66        git branch
     67            Lists all local branches in the current directory
     68        git branch [branch-name]
     69            Create a new branch
     70        git checkout [branch-name]
     71            Switches to the specified branch and updates the working directory
     72        git checkout -b <name> <remote>/<branch>
     73            Switches to a remote branch
     74        git checkout [filename]
     75            Return file to it's previous version, if it hasn’t been staged yet
     76        git merge [branch]
     77            Combines the specified branch's history into the current branch
     78        git merge –no–ff [branch]
     79            Merge branch without fast forwarding
     80        git branch -a
     81            See the full list of local and remote branches
     82        git branch -d [branch]
     83            Deletes the specified branch
     84        git branch -D [branch]
     85            Hard branch delete, will not complain
     86        git branch -m <oldname> <newname>
     87            Rename a branch
     88
     89    Refactor filenames
     90        git rm [file]
     91            Deletes the file from the working directory and stages the deletion
     92        git rm –cached [file]
     93            Removes the file from version control but preserves the file locally
     94        git mv [file-original] [file-renamed]
     95            Changes the file name and prepares it for commit
     96
     97    Suppress tracking
     98        .gitignore
     99            *.log
     100            build/
     101            temp-*
     102            A text file named .gitignore suppresses accidental versioning of files and paths matching the specified patterns
     103        git ls-files –other –ignored –exclude-standard
     104            Lists all ignored files in this project
     105
     106    Save fragments
     107        git stash
     108            Temporarily stores all modified tracked files
     109        git stash pop
     110            Restores the most recently stashed files
     111        git stash list
     112            Lists all stashed changesets
     113        git stash drop
     114            Discards the most recently stashed changeset
     115
     116    Review history
     117        git log
     118            Lists version history for the current branch
     119        git log –follow [file]
     120            Lists version history for a file, including renames
     121        git log –pretty=format:"%h %s" –graph
     122            Pretty commit view, you can customize it as much as you want
     123        git log –author='Name' –after={1.week.ago} –pretty=oneline –abbrev-commit
     124            See what the author has worked on in the last week
     125        git log –no-merges master..
     126            See only changes in this branch
     127        git diff [file-branch]…[second-branch]
     128            Shows content differences between two branches
     129        git show [commit]
     130            Outputs metadata and content changes of the specified commit
     131
     132    Redo commits
     133        git reset
     134            Unstage pending changes, the changes will still remain on file system
     135        git reset [commit/tag]
     136            Undoes all commits after [commit], preserving changes locally
     137        git reset –hard [commit]
     138            Discards all history and changes back to the specified commit
     139
     140    Synchronize changes
     141        git fetch [bookmark]
     142            Downloads all history from the repository bookmark
     143        git fetch -p
     144            Update history of remote branches, you can fetch and purge
     145        git merge [bookmark]/[branch]
     146            Combines bookmark's branch into current local branch
     147        git push
     148            Push current branch to remote branch
     149        git push [remote] [branch]
     150            Manually specify remote and branch to use every time
     151        git push -u origin master
     152            If a remote branch is not set up as an upstream, you can make it so
     153        git pull
     154            Downloads bookmark history and incorporates changes
     155        git pull [remote] [branch]
     156            Specify to pull a specific branch
     157        git remote
     158            See list of remote repos available
     159        git remote -v
     160            Detailed view of remote repos available
     161        git remote add [remote] [url]
     162            Add a new remote