Project

General

Profile

Git settings » History » Version 2

Alexander Watzinger, 2022-01-13 15:45

1 1 Alexander Watzinger
h2. Useful git configuration settings
2
3
These options can be configured in your global git config file e.g. ~/.gitconfig on Linux:
4
<pre>
5
[user]
6
        name = Your Name
7
        email = your@email.net
8
[color]
9
        ui = true
10
[core]
11
        editor = vim
12
[fetch]
13
        prune = true
14
[merge]
15
        tool = meld
16
[mergetool]
17
        keepBackup = false
18 2 Alexander Watzinger
[pull]
19
        rebase = false
20 1 Alexander Watzinger
[status]
21
        showUntrackedFiles = all
22
</pre>
23
Or using shell commands e.g.
24
25
<pre>
26
git config --global fetch.prune true
27
</pre>
28
29
h2. Prompt with branch and dirty indicator 
30
31
<pre>
32
vim ~/.bashrc
33
</pre>
34
<pre>
35
function parse_git_dirty {
36
    [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" 
37
}
38
function parse_git_branch {
39
    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" 
40
}
41
PS1='\[\e[1;34m\]\u@\h:\w\[\e[0;32m\]$(parse_git_branch)\[\e[1;34m\]\$ \[\e[m\]'
42
</pre>