Git: How to view file diff before commit
You’re looking for git diff. Depending on your exact situation, there are three useful ways to use it:
1 2 3 4 5 6 7 8 |
# show differences between index and working tree # that is, changes you haven't staged to commit git diff [filename] # show differences between current commit and index # that is, what you're about to commit git diff --cached [filename] # show differences between current commit and working tree git diff HEAD [filename] |
It’ll work recursively on directories, and if no paths are given, it shows all changes.
Git: git ignore files only locally(Prevent local changes getting pushed in Git)
http://stackoverflow.com/questions/1753070/git-ignore-files-only-locally
Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user’s workflow) should go into the
$GIT_DIR/info/exclude
file.
The .git/info/exclude
file has the same format as any .gitignore
file. You can also set core.excludesfile
to the name of a file containing global patterns.
If you already have unstaged changes you must then run:
1 2 |
git update-index --assume-unchanged [<file>...] |
To get it back if one day you need it:
1 |
git update-index --no-assume-unchanged filename |
Note on $GIT_DIR
: This is a notation used all over the git manual simply to indicate the path to the git repository. If the environment variable is set, then it will override the location of whichever repo you’re in, which probably isn’t what you want.
Git commads
Checkout remote branch
1 2 |
git fetch git checkout test |