Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
git-tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Nilsson
git-tutorial
Commits
c6d834cf
Commit
c6d834cf
authored
12 years ago
by
Administrator
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parents
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+4
-0
4 additions, 0 deletions
.gitignore
git-tutorial.tex
+142
-0
142 additions, 0 deletions
git-tutorial.tex
lifecycle.png
+0
-0
0 additions, 0 deletions
lifecycle.png
with
146 additions
and
0 deletions
.gitignore
0 → 100644
+
4
−
0
View file @
c6d834cf
*.aux
*.log
*~
git-tutorial.pdf
This diff is collapsed.
Click to expand it.
git-tutorial.tex
0 → 100644
+
142
−
0
View file @
c6d834cf
\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
}
This diff is collapsed.
Click to expand it.
lifecycle.png
0 → 100644
+
0
−
0
View file @
c6d834cf
44.4 KiB
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment