Move other configuration commands
This commit is contained in:
parent
5b8c8fb6a5
commit
db547ce1fe
90
README.md
90
README.md
|
@ -25,6 +25,10 @@ For clarity's sake all examples in this document use a customized bash prompt in
|
|||
- [Configuration](#configuration)
|
||||
- [I want to set a global user](#i-want-to-set-a-global-user)
|
||||
- [I want to add command line coloring for Git](#i-want-to-add-command-line-coloring-for-git)
|
||||
- [I want to add aliases for some Git commands](#i-want-to-add-aliases-for-some-git-commands)
|
||||
- [I want to add an empty directory to my repository](#i-want-to-add-an-empty-directory-to-my-repository)
|
||||
- [I want to cache a username and password for a repository](#i-want-to-cache-a-username-and-password-for-a-repository)
|
||||
- [I want to make Git ignore permissions and filemode changes](#i-want-to-make-git-ignore-permissions-and-filemode-changes)
|
||||
- [Repositories](#repositories)
|
||||
- [I want to start a local repository](#i-want-to-start-a-local-repository)
|
||||
- [I want to clone a remote repository](#i-want-to-clone-a-remote-repository)
|
||||
|
@ -108,11 +112,6 @@ For clarity's sake all examples in this document use a customized bash prompt in
|
|||
- [I want to overwrite local files when doing a git pull](#i-want-to-overwrite-local-files-when-doing-a-git-pull)
|
||||
- [I want to remove a file from Git but keep the file](#i-want-to-remove-a-file-from-git-but-keep-the-file)
|
||||
- [I want to revert a file to a specific revision](#i-want-to-revert-a-file-to-a-specific-revision)
|
||||
- [Configuration](#configuration-1)
|
||||
- [I want to add aliases for some Git commands](#i-want-to-add-aliases-for-some-git-commands)
|
||||
- [I want to add an empty directory to my repository](#i-want-to-add-an-empty-directory-to-my-repository)
|
||||
- [I want to cache a username and password for a repository](#i-want-to-cache-a-username-and-password-for-a-repository)
|
||||
- [I want to make Git ignore permissions and filemode changes](#i-want-to-make-git-ignore-permissions-and-filemode-changes)
|
||||
- [I've no idea what I did wrong](#ive-no-idea-what-i-did-wrong)
|
||||
- [Other Resources](#other-resources)
|
||||
- [Books](#books)
|
||||
|
@ -149,6 +148,83 @@ To set automatic command line coloring for Git for easy reviewing:
|
|||
$ git config --global color.ui auto
|
||||
```
|
||||
|
||||
<a name="adding-command-aliases"></a>
|
||||
### I want to add aliases for some Git commands
|
||||
|
||||
On OS X and Linux, your git configuration file is stored in ```~/.gitconfig```. I've added some example aliases I use as shortcuts (and some of my common typos) in the ```[alias]``` section as shown below:
|
||||
|
||||
```vim
|
||||
[alias]
|
||||
a = add
|
||||
amend = commit --amend
|
||||
c = commit
|
||||
ca = commit --amend
|
||||
ci = commit -a
|
||||
co = checkout
|
||||
d = diff
|
||||
dc = diff --changed
|
||||
ds = diff --staged
|
||||
f = fetch
|
||||
loll = log --graph --decorate --pretty=oneline --abbrev-commit
|
||||
m = merge
|
||||
one = log --pretty=oneline
|
||||
outstanding = rebase -i @{u}
|
||||
s = status
|
||||
unpushed = log @{u}
|
||||
wc = whatchanged
|
||||
wip = rebase -i @{u}
|
||||
zap = fetch -p
|
||||
```
|
||||
|
||||
<a name="adding-empty-repository"></a>
|
||||
### I want to add an empty directory to my repository
|
||||
|
||||
You can’t! Git doesn’t support this, but there’s a hack. You can create a .gitignore file in the directory with the following contents:
|
||||
|
||||
```
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
||||
```
|
||||
|
||||
Another common convention is to make an empty file in the folder, titled .gitkeep.
|
||||
|
||||
```sh
|
||||
$ mkdir mydir
|
||||
$ touch mydir/.gitkeep
|
||||
```
|
||||
|
||||
You can also name the file as just .keep , in which case the second line above would be ```touch mydir/.keep```
|
||||
|
||||
<a name="credential-helper"></a>
|
||||
### I want to cache a username and password for a repository
|
||||
|
||||
You might have a repository that requires authentication. In which case you can cache a username and password so you don't have to enter it on every push / pull. Credential helper can do this for you.
|
||||
|
||||
```sh
|
||||
$ git config --global credential.helper cache
|
||||
# Set git to use the credential memory cache
|
||||
```
|
||||
|
||||
```sh
|
||||
$ git config --global credential.helper 'cache --timeout=3600'
|
||||
# Set the cache to timeout after 1 hour (setting is in seconds)
|
||||
```
|
||||
|
||||
<a name="i-want-to-make-git-ignore-permissions-and-filemode-changes"></a>
|
||||
### I want to make Git ignore permissions and filemode changes
|
||||
|
||||
```sh
|
||||
$ git config core.fileMode false
|
||||
```
|
||||
|
||||
If you want to make this the default behaviour for logged-in users, then use:
|
||||
|
||||
```sh
|
||||
$ git config --global core.fileMode false
|
||||
```
|
||||
|
||||
## Repositories
|
||||
|
||||
### I want to start a local repository
|
||||
|
@ -1377,6 +1453,7 @@ If you want to revert to changes made just 1 commit before c5f567, pass the comm
|
|||
(master)$ git checkout c5f567~1 -- file1/to/restore file2/to/restore
|
||||
```
|
||||
|
||||
<<<<<<< HEAD
|
||||
## Configuration
|
||||
|
||||
<a name="adding-command-aliases"></a>
|
||||
|
@ -1455,6 +1532,9 @@ If you want to make this the default behaviour for logged-in users, then use:
|
|||
$ git config --global core.fileMode false
|
||||
```
|
||||
|
||||
=======
|
||||
<a href="#ive-no-idea-what-i-did-wrong"></a>
|
||||
>>>>>>> Move other configuration commands
|
||||
## I've no idea what I did wrong
|
||||
|
||||
So, you're screwed - you `reset` something, or you merged the wrong branch, or you force pushed and now you can't find your commits. You know, at some point, you were doing alright, and you want to go back to some state you were at.
|
||||
|
|
Loading…
Reference in New Issue