7 \frametitle{Table of contents
}
11 \section{Introduction
}
13 \frametitle{Who am I?
}
16 \item 4th year bachelor AI
17 \item \url{https://github.com/dopefishh/gitflashtalk
}
18 \item SHA of the commit of this presentation:
24 \frametitle{Where did GIT come from?
}
25 \begin{block
}{History
}
26 \begin{columns
} \column{0.4\linewidth}
28 \item Pronounce:
\textipa{[g\'
\i t
]}
33 \column{0.5\linewidth}
36 \includegraphics[width=
0.5\linewidth]{1.png
}
37 \caption{Linus Torvalds
}
42 \begin{block
}{What is GIT?
}
56 \item Support for non linear development
57 \item Intermediate stage between committing and pushing
64 \item Intermediate stage between committing and pushing
69 \section{Installation
}
70 \begin{frame
}[fragile
]
71 \begin{block
}{{\Large\Smiley\Smiley} Linux
}
72 Depending on the distribution you may have to do:\\
73 \texttt{\# apt-get install git
}\\
74 \texttt{\# pacman -S git
}\\
75 \texttt{\# yum install git
}\\
76 \texttt{\# emerge --ask dev-vcs/git
}\\
80 \begin{block
}{{\Large\Frowny\Smiley} Mac
}
81 Install via XCode tools. Just run
\lstinline{$\$$ git
} and
82 when GIT is not installed it will prompt you with instructions.
85 \begin{block
}{{\Large\Frowny\Frowny} Windows
}
86 Downoad the binary from
\url{http://git-scm.com/download/win
} and install.
91 \section{Getting started \& workflow
}
92 \begin{frame
}[fragile
]
93 \frametitle{Getting started
}
94 \begin{block
}{Check GIT version in (GIT) bash
}
96 frobnicator@frobmachine:~$\$$ git --version
101 \begin{block
}{Create a repository
}
103 frobnicator@frobmachine:~/projects$\$$ git init myfirstproject
104 Initialized empty Git repository in /home/frobnicator/projects/myfirstproject/.git/
106 frobnicator@frobmachine:~/projects$\$$ ls -
1 myfirstproject/.git
120 \frametitle{Four (five) stages
}
131 \frametitle{Workflow
}
134 \includegraphics[scale=
0.4]{2.png
}
135 \caption{Git workflow
}
139 \section{Everything is a commit
}
140 \begin{frame
}[fragile
]
141 \frametitle{Add and commit
}
143 frobnicator@frobmachine:~/projects/myfirstproject$\$$ echo "This is a frobfile" > frobbedfile
145 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git status
151 (use "git add <file>..." to include in what will be committed)
155 nothing added to commit but untracked files present (use "git add" to track)
159 \begin{frame
}[fragile
]
161 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git add frobbedfile
163 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git status
168 Changes to be committed:
169 (use "git rm --cached <file>..." to unstage)
171 new file: frobbedfile
173 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git commit
174 [master (root-commit)
2b7355e
] Adds frobbedfile
175 1 file changed,
1 insertion(+)
176 create mode
100644 frobbedfile
180 \begin{frame
}[fragile
]
181 \frametitle{Log \& Checkout
}
183 frobnicator@frobmachine:~/projects/myfirstproject$\$$ echo "This is a second frobbedfile" > frob2
184 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git add frob2
185 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git commit -m "This is a second commit"
186 [master cd094bc
] This is a second commit
187 1 file changed,
1 insertion(+)
188 create mode
100644 frob2
192 \begin{frame
}[fragile
]
193 \frametitle{Log \& Checkout
2}
195 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git log
196 commit cd094bc6b81812256533395454db22da07d1e5a4
197 Author: Frob Nicator <frob@nicator.net>
198 Date: Thu Apr
16 22:
44:
42 2015 +
0200
200 This is a second commit
202 commit c9c9b358cddcbee541ec433a2dc2d5ffe3e928c2
203 Author: Frob Nicator <frob@nicator>
204 Date: Thu Apr
16 22:
44:
42 2015 +
0200
207 frobnicator@frobmachine:~/projects/myfirstproject$\$$ ls
212 \begin{frame
}[fragile
]
213 \frametitle{Log \& Checkout
2}
215 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git checkout c9c9b3
216 Note: checking out 'c9c9b3'.
218 You are in 'detached HEAD' state. You can look around, make experimental
219 changes and commit them, and you can discard any commits you make in this
220 state without impacting any branches by performing another checkout.
222 If you want to create a new branch to retain commits you create, you may
223 do so (now or later) by using -b with the checkout command again. Example:
225 git checkout -b new_branch_name
227 HEAD is now at c9c9b35... Adds frobbedfile
228 frobnicator@frobmachine:~/projects/myfirstproject$\$$ ls
233 \begin{frame
}[fragile
]
234 \frametitle{Log \& Checkout
3}
235 \framesubtitle{We lost our commit and our file!
}
237 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git log
238 commit c9c9b358cddcbee541ec433a2dc2d5ffe3e928c2
239 Author: Frob Nicator <frob@nicator>
240 Date: Thu Apr
16 22:
44:
42 2015 +
0200
243 frobnicator@frobmachine:~/projects/myfirstproject$\$$ ls
248 \begin{frame
}[fragile
]
249 \frametitle{Log \& Checkout
4}
250 \begin{block
}{Ofcourse not, you never lose stuff with git
}
252 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git log --all
253 commit cd094bc6b81812256533395454db22da07d1e5a4
254 Author: Frob Nicator <frob@nicator.net>
255 Date: Thu Apr
16 22:
44:
42 2015 +
0200
257 This is a second commit
264 \begin{frame
}[fragile
]
265 \frametitle{Log \& Checkout
5}
266 \begin{block
}{We can just checkout the hash again
}
268 frobnicator@frobmachine:~/projects/myfirstproject$\$$ ls
270 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git log --decorate --oneline --graph --all
271 * cd094bc (HEAD, master) This is a second commit
272 * c9c9b35 Adds frobbedfile
278 \section{Branching and unevitable merging
}
280 \frametitle{Branching
}
282 \item Commit: State of the folder. Has and knows his parent.\\
283 \item Branch: Just a named commit.\\
284 Usually a sidetrack of a project.\\
285 Master, develop, feature, etc
\ldots
286 \item Tag: Just a named commit.\\
287 Usually marked point to jump to later on.\\
288 eg. Version release, big change etc
\ldots
292 \begin{frame
}[fragile
]
293 \frametitle{Branching
2}
294 \begin{block
}{See current branch
}
296 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git branch
300 \begin{block
}{Create new branch
}
302 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git checkout -b "develop"
303 Switched to a new branch 'develop'
304 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git branch
309 \begin{block
}{Delete branch
}
311 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git branch -d "develop"
312 Deleted branch develop (was cd094bc).
313 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git branch
319 \begin{frame
}[fragile
]
320 \frametitle{Push \& Pull
}
323 \item Push your changes upsteam repository (eg.\ github)
324 \item Pull their changes from upstream
325 \item Merge into your branch
330 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git remote add origin https://github.com/dopefishh/prj.git
331 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git push origin master
332 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git pull origin master
337 \begin{frame
}[fragile
]
339 \begin{block
}{Merge develop to master
}
341 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git merge develop
345 \begin{block
}{How to get a conflict
}
347 \item We make a file with three lines
348 \item On every line we set:
\texttt{regelN
} where N is line
350 \item Change line
2 in the master and develop branch to a
352 \item Commit both and checkout master
358 \begin{frame
}[fragile
]
360 \begin{block
}{Merge message
}
362 frobnicator@frobmachine~/projects/myfirstproject$\$$ git merge develop
363 Auto-merging mergeconfict
364 CONFLICT (content): Merge conflict in mergeconfict
365 Automatic merge failed; fix conflicts and then commit the result.
368 \begin{block
}{Contents of mergeconflict file
}
381 \begin{frame
}[fragile
]
383 \begin{block
}{Commit message
}
385 1 Merge branch 'develop'
390 6 # It looks like you may be committing a merge.
391 7 # If this is not correct, please remove the file
396 12 # Please enter the commit message for your changes. Lines starting
397 13 # with '#' will be ignored, and an empty message aborts the commit.
398 14 # On branch master
399 15 # All conflicts fixed but you are still merging.
401 17 # Changes to be committed:
402 18 # modified: mergeconfict
408 \begin{frame
}[fragile
]
410 \begin{block
}{Output from git log
}
412 * a6474c9 (HEAD, master) Merge branch 'develop'
414 | *
8b292ad (develop) Develop merge conflict
415 * |
7d5018a Master merge confict
417 *
885a341 First merge conflict push
418 * cd094bc This is a second commit
419 * c9c9b35 Adds frobbedfile
424 \section{Tips \& Tricks
}
425 \begin{frame
}[fragile
]
426 \frametitle{\texttt{/home/frobnicator/.gitconfig
}}
428 frobnicator@frobmachine~$\$$ cat .gitconfig
431 email = frob@nicator.com
434 tree = log --decorate --oneline --graph --all
435 pushm = push origin master
436 pushd = push origin develop
440 \begin{frame
}[fragile
]
441 \frametitle{Public key
}
442 \begin{block
}{SSH config
}
444 frobnicator@frobmachine:~$\$$ cat .ssh/config
446 IdentityFile /home/frobnicator/.ssh/github
450 \begin{block
}{Create Key
}
452 frobnicator@frobmachine:~ $\$$ ssh-keygen -f /home/frobnicator/.ssh/github
455 \begin{block
}{Clone with ssh
}
457 frobnicator@frobmachine:~/projects/myfirstproject$\$$ git remote add origin git@github.com:frobnicator/prj.git
458 frobnicator@frobmachine:~/projects/$\$$ git clone git@github.com:frobnicator/prj.git