Git: Difference between revisions

remove template
m Text replacement - "<(\/?)source" to "<$1syntaxhighlight"
Line 24: Line 24:
== Initial Configuration ==
== Initial Configuration ==
In your [https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup first time setting up Git on a new computer], you want to configure your username and email among other settings.
In your [https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup first time setting up Git on a new computer], you want to configure your username and email among other settings.
<source lang="bash">
<syntaxhighlight lang="bash">
git config --global user.name "Greg Rundlett"
git config --global user.name "Greg Rundlett"
git config --global user.email greg@freephile.com
git config --global user.email greg@freephile.com
Line 39: Line 39:
# and adopt the new behavior now, use:
# and adopt the new behavior now, use:
git config --global push.default simple
git config --global push.default simple
</source>
</syntaxhighlight>
=== Example .gitconfig ===
=== Example .gitconfig ===
<code>git config --global -e</code> and paste in the following:
<code>git config --global -e</code> and paste in the following:
<source lang="ini">
<syntaxhighlight lang="ini">
[user]
[user]
         name = Greg Rundlett
         name = Greg Rundlett
Line 97: Line 97:
#      browser = google-chrome
#      browser = google-chrome
         browser = firefox
         browser = firefox
</source>
</syntaxhighlight>


{{Highlight
{{Highlight
Line 110: Line 110:
Using multiple repositories to compose your project.  See https://git-scm.com/book/en/v2/Git-Tools-Submodules
Using multiple repositories to compose your project.  See https://git-scm.com/book/en/v2/Git-Tools-Submodules


<source lang="bash">
<syntaxhighlight lang="bash">
git init myproject
git init myproject
cd myproject
cd myproject
Line 134: Line 134:
git config alias.spush 'push --recurse-submodules=on-demand'
git config alias.spush 'push --recurse-submodules=on-demand'
git config alias.supdate 'submodule update --remote --merge'
git config alias.supdate 'submodule update --remote --merge'
</source>
</syntaxhighlight>


== Tools ==
== Tools ==
Line 144: Line 144:
== Reporting ==
== Reporting ==
How many lines have I contributed since last year?
How many lines have I contributed since last year?
<source lang="bash">
<syntaxhighlight lang="bash">
git log --stat --author $(git config --get user.email) --since="last year" --until="last month" | awk -F',' '/files? changed/ {
git log --stat --author $(git config --get user.email) --since="last year" --until="last month" | awk -F',' '/files? changed/ {
     files += $1
     files += $1
Line 158: Line 158:


}'
}'
</source>
</syntaxhighlight>


== Visualizing ==
== Visualizing ==
Line 225: Line 225:
Generally following the series of instructions at
Generally following the series of instructions at
http://vafer.org/blog/20080115011413  I installed Git-core, gitweb and gitosis on the  host
http://vafer.org/blog/20080115011413  I installed Git-core, gitweb and gitosis on the  host
<source lang="bash">
<syntaxhighlight lang="bash">
# install git, the git-svn tool and the viewvc equivalent
# install git, the git-svn tool and the viewvc equivalent
apt-get install git-core git-svn gitweb
apt-get install git-core git-svn gitweb
Line 305: Line 305:
# and install it
# and install it
apt-get install gitosis
apt-get install gitosis
</source>
</syntaxhighlight>