Commit 24ae7381 authored by Jeroen F.J. Laros's avatar Jeroen F.J. Laros

Merge remote-tracking branch 'origin/remotes'

parents dec2c6c1 a0bf3d38
/local/projects/presentation/trunk/Makefile
\ No newline at end of file
/local/projects/presentation/trunk/beamerthemelumc.sty
\ No newline at end of file
/local/projects/presentation/trunk/gen2phen_logo.eps
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/local/projects/presentation/trunk/lgtc_logo.eps
\ No newline at end of file
/local/projects/presentation/trunk/lumc_logo.eps
\ No newline at end of file
/local/projects/presentation/trunk/lumc_logo_small.eps
\ No newline at end of file
/local/projects/presentation/trunk/nbic_logo.eps
\ No newline at end of file
/local/projects/presentation/trunk/ngi_logo.eps
\ No newline at end of file
/local/projects/presentation/trunk/nwo_logo_en.eps
\ No newline at end of file
\documentclass[slidestop]{beamer}
\title{Git and remote repositories}
\providecommand{\myConference}{Git course}
\providecommand{\myDate}{Monday, October 14, 2013}
\author{Martijn Vermaat}
\providecommand{\myGroup}{Leiden Genome Technology Center}
\providecommand{\myDepartment}{Department of Human Genetics}
\providecommand{\myCenter}{Center for Human and Clinical Genetics}
\providecommand{\lastCenterLogo}{
\raisebox{-0.1cm}{
\includegraphics[height=1cm]{lgtc_logo}
%\includegraphics[height=0.7cm]{ngi_logo}
}
}
\providecommand{\lastRightLogo}{
%\includegraphics[height=0.7cm]{nbic_logo}
%\includegraphics[height=0.8cm]{nwo_logo_en}
%\hspace{1.5cm}\includegraphics[height=0.7cm]{gen2phen_logo}
}
\usetheme{lumc}
\lstset{
basicstyle=\ttfamily,
language=none,
frame=none,
numbers=none,
numbersep=0
}
\AtBeginSection[]
{
\begin{frame}
\frametitle{Table of contents}
\tableofcontents[currentsection]
\end{frame}
}
\begin{document}
% This disables the \pause command, handy in the editing phase.
%\renewcommand{\pause}{}
% Make the title page.
\bodytemplate
\section{Remote repositories}
\begin{frame}
\frametitle{Distributed Git}
Repositories can reference each other:
\begin{itemize}
\item A repository can be on a server, your desktop, your coworker's
laptop, etc.
\item Technically, no repository is `special'.
\item We call a reference to another repository a {\em remote}.
\end{itemize}
\pause
\bigskip
\includegraphics[width=6cm]{images/repositories}
\end{frame}
\begin{frame}[fragile]
\frametitle{Listing remotes}
\begin{lstlisting}
$ git remote
gitlab
\end{lstlisting}
\bigskip
We are on \bt{aida} and have one remote, \bt{gitlab}, defined.
\pause
\bigskip
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
$ git remote -v
gitlab https://git.lumc.nl/m.vermaat.hg/tv-series.git (fetch)
gitlab https://git.lumc.nl/m.vermaat.hg/tv-series.git (push)
\end{lstlisting}
\bigskip
\bt{-v}: Include remote location.\\
\vspace{1cm}
We see that communication with \bt{gitlab} is over HTTPS.
\end{frame}
\begin{frame}[fragile]
\frametitle{Adding a remote: \bt{git remote add}}
\begin{lstlisting}
$ git remote add hue 192.168.0.8:projects/tv-series
\end{lstlisting}
\bigskip
This adds a reference to the remote repository \bt{hue} using communication
over SSH.
\pause
\bigskip
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
$ git remote -v
gitlab https://git.lumc.nl/m.vermaat.hg/tv-series.git (fetch)
gitlab https://git.lumc.nl/m.vermaat.hg/tv-series.git (push)
hue 192.168.0.8:projects/tv-series (fetch)
hue 192.168.0.8:projects/tv-series (push)
\end{lstlisting}
\end{frame}
\begin{frame}
\frametitle{Remote branches}
You see code from remotes as {\em remote branches}:
\begin{itemize}
\item Remote branches are just branches prefixed with the remote name.
\item Communicate with remotes to update the remote branches.
\item You can setup a local branch to {\em track} a remote branch.
\end{itemize}
\pause
\bigskip
\includegraphics[width=10cm]{images/example}
\end{frame}
\begin{frame}[fragile]
\frametitle{Listing remote branches: \bt{git branch}}
\begin{lstlisting}
$ git branch -v
* master f1ef19c State character preference
\end{lstlisting}
\bigskip
This shows only our local branches.
\pause
\bigskip
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
$ git branch -v -a
* master f1ef19c State character preference
remotes/gitlab/master f1ef19c State character preference
\end{lstlisting}
\bigskip
\bt{-a}: Include remote branches.
\end{frame}
\begin{frame}[fragile]
\frametitle{Updating remote branches: \bt{git fetch}}
\begin{lstlisting}
$ git fetch hue
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From 192.168.0.8:projects/tv-series
* [new branch] master -> hue/master
* [new branch] simpsons -> hue/simpsons
\end{lstlisting}
\pause
\bigskip
\includegraphics[width=10cm]{images/example-hue}
\end{frame}
\begin{frame}[fragile]
\frametitle{Merging remote branches: \bt{git merge}}
We can merge remote branches just like normal branches.
\bigskip
\begin{lstlisting}
$ git merge hue/simpsons
...
\end{lstlisting}
\pause
\bigskip
Alternatively, we could continue the work of a remote branch.
\end{frame}
\begin{frame}[fragile]
\frametitle{Creating a local tracking branch: \bt{git checkout}}
Remote branches are `read-only':
\begin{itemize}
\item We cannot directly continue work on a remote branch.
\item But we can setup a local {\em tracking branch}.
\end{itemize}
\bigskip
\begin{lstlisting}
$ git checkout simpsons
Branch simpsons set up to track remote branch
simpsons from hue.
Switched to a new branch 'simpsons'
\end{lstlisting}
\bigskip
What happened here?
\begin{itemize}
\item There was no branch \bt{simpsons}.
\item But there was a remote branch of the same name.
\item So Git creates a new branch based on that (and switches to it).
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Working on a tracking branch}
Let's continue working on branch \bt{simpsons}.
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
$ emacs FACTS.md
$ git commit -am 'Edit character presence'
[simpsons 0676334] Edit character presence
1 file changed, 1 insertion(+), 1 deletion(-)
$ git status
# On branch simpsons
# Your branch is ahead of 'hue/simpsons' by 1 commit.
#
nothing to commit (working directory clean)
\end{lstlisting}
\bigskip
\includegraphics[width=9cm]{images/example-commit}
\end{frame}
\begin{frame}[fragile]
\frametitle{Pushing changes to a remote: \bt{git push}}
\begin{lstlisting}
$ git push hue simpsons
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 303 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To hue.remote:projects/tv-series
0535b7e..0676334 simpsons -> simpsons
\end{lstlisting}
\bigskip
Our work on branch \bt{simpsons} is now available on remote \bt{hue} too.
\end{frame}
\begin{frame}[fragile]
\frametitle{Cloning an existing repository}
Instead of creating repositories using \bt{git init}, you can create a local
{\em clone} of an existing (remote) repository.
\bigskip
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
$ git clone https://git.lumc.nl/m.vermaat.hg/tv-series.git
Cloning into 'tv-series'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
\end{lstlisting}
\pause
\bigskip
A remote called \bt{origin} is added for the original repository and branch
\bt{master} is setup to track the original \bt{master}.
\bigskip
\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
$ cd tv-series/
$ git remote -v
origin https://git.lumc.nl/m.vermaat.hg/tv-series.git (fetch)
origin https://git.lumc.nl/m.vermaat.hg/tv-series.git (push)
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Shortcuts for tracking branches}
If a local branch is setup to track a remote branch, there are shortcuts for
synchronizing them.\\
\pause
\vspace{1cm}
For example, say \bt{HEAD} is on \bt{simpsons} which is tracking
\bt{origin/simpsons}.
\bigskip
\begin{lstlisting}
$ git push ==> $ git push origin simpsons
\end{lstlisting}
\bigskip
\begin{lstlisting}
$ git pull ==> $ git fetch origin
$ git merge origin/simpsons
\end{lstlisting}
\end{frame}
\section{Working with GitLab}
\begin{frame}
\frametitle{Using a central server}
Git can be used by a team completely decentralized.\\
\vspace{0.5cm}
However, often a central server is used:
\begin{itemize}
\item It can be easier to communicate via the server.
\item It can be convenient to have a canonical repository.
\item Services such as {\em GitLab} and {\em GitHub} add many features on
top of Git.
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{GitLab}
Our GitLab server is at \bt{https://git.lumc.nl/}\\
\vspace{0.5cm}
\begin{itemize}
\item Coupled to your LUMC account.
\item All users can create projects.
\item Browse repositories and edit files online.
\item Control access for other users.
\item Track bugs/issues/tickets.
\item Create merge requests and do code reviews.
\end{itemize}
\end{frame}
% todo: create gitlab project, clone gitlab project
\section{Questions?}
\lastpagetemplate
\begin{frame}
\begin{center}
Acknowledgements:
\bigskip
\bigskip
Jeroen Laros
Zuotian Tatum
% https://www.atlassian.com/git
\end{center}
\end{frame}
\end{document}
/local/projects/presentation/trunk/ul_logo.eps
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment