Skip to content
Snippets Groups Projects
Commit c6d834cf authored by Administrator's avatar Administrator
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
*.aux
*.log
*~
git-tutorial.pdf
\documentclass[a4paper,11pt,twoside]{article}
\usepackage{a4wide}
\usepackage{palatino}
\usepackage{tikz}
\usepackage{listings}
\title{Git Tutorial\\ \tiny{Version: 0.1}}
\author{Anders Nilsson \\
\texttt{andersn@control.lth.se}}
\lstset{
frame=single,
basicstyle=\footnotesize\ttfamily
}
\begin{document}
\maketitle{}
\section{Introduction}
\label{sec:intro}
\section{Git Tools}
\label{sec:tools}
\section{Hands-On Excercise}
\label{sec:handson}
\begin{figure}[h!]
\centering
\pgfimage[width=.9\textwidth]{lifecycle.png}
\caption{Files go through the following stages as you work on them.}
\label{fig:lifecycle}
\end{figure}
\subsubsection*{First time configuration}
On each computer (or for each user account) you need to tell git your
name and email address. These are used in each commit to make it
possible to see who has performed which commits to a shared
repository.
\begin{lstlisting}
git config --global user.name "Anders Nilsson"
git config --global user.email "andersn@control.lth.se"
\end{lstlisting}
You can always see which name and/or email, if any, git thinks you have:
\begin{lstlisting}
git config --global --get user.name
\end{lstlisting}
\subsubsection*{Create a Repository}
\label{create}
Let us say we have a directory with files that we want to version
control using git.
\begin{lstlisting}
andersn@stodola:../computers/git-tutorial$ pwd
/local/home/andersn/work/computers/git-tutorial
andersn@stodola:../computers/git-tutorial$ ls
git-tutorial.aux git-tutorial.pdf git-tutorial.tex
lifecycle.png git-tutorial.log #git-tutorial.tex#
git-tutorial.tex~
\end{lstlisting}
We can now create a new repository in this directory
\begin{lstlisting}
andersn@stodola:../computers/git-tutorial$ git init
\end{lstlisting}
The result of this command is a new subdirectory called \verb|.git|
that contains the actual git repository. If you look into it you will
see various files and subdirectories.
\begin{lstlisting}
andersn@stodola:../computers/git-tutorial$ ls .git/
branches config description HEAD hooks info objects refs
\end{lstlisting}
Some of these are human readable while others are not. If you are
curious you can navigate the subdirectories and try to look into
files. Or don't, there is almost never any need to look into this
directory.
\subsubsection*{Adding Files}
\label{addfiles}
As you have seen above there are directory we do not want
to version control. The only files here that should go into git are
\verb|git-tutorial.tex| and \verb|lifecycle.png|, the rest are either
temporary files from emacs and \LaTeX or a pdf file which is generated
from the \LaTeX source. We will take care of that when it is time to
add files to the repository.
\begin{lstlisting}
andersn@stodola:../computers/git-tutorial$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# git-tutorial.aux
# git-tutorial.log
# git-tutorial.pdf
# git-tutorial.tex
# git-tutorial.tex~
# lifecycle.png
nothing added to commit but untracked files present (use "git add" to track)
\end{lstlisting}
\begin{lstlisting}
andersn@stodola:../computers/git-tutorial$ git add lifecycle.png git-tutorial.tex
andersn@stodola:../computers/git-tutorial$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: git-tutorial.tex
# new file: lifecycle.png
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .#git-tutorial.tex
# git-tutorial.aux
# git-tutorial.log
# git-tutorial.pdf
# git-tutorial.tex~
\end{lstlisting}
\begin{lstlisting}
\end{lstlisting}
\end{document}
lifecycle.png

44.4 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment