Skip to content

Commit bdd7fa4

Browse files
committed
Updates and improvements in the Git chapter.
1 parent a69fe45 commit bdd7fa4

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

presentation/linux_bash_metacentrum_course.tex

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4601,7 +4601,7 @@ \subsection{Git principle}
46014601
46024602
\begin{frame}[allowframebreaks]{Git and version control}
46034603
\begin{itemize}
4604-
\item \href{https://git-scm.com/}{Git} is \href{https://en.wikipedia.org/wiki/Version_control}{version controlling} system --- it traces changes among all versions --- absolutely crucial for any software development
4604+
\item \href{https://git-scm.com/}{Git} is \href{https://en.wikipedia.org/wiki/Version_control}{version controlling} system (nowadays the most common) --- it traces changes among all versions --- absolutely crucial for any software development
46054605
\item Older (nowadays not so common) version controlling systems is Subversion (SVN), there are many more (Bazaar, Mercurial,~\ldots)
46064606
\item Probably the best textbook for Git is \href{https://git-scm.com/book/en/v2}{Chacon's Pro Git}
46074607
\begin{itemize}
@@ -4610,27 +4610,22 @@ \subsection{Git principle}
46104610
\item Changes and their history is stored in repository (local or network, shared or private) --- it is possible to view any historical state and differences between any versions
46114611
\item It is possible to trace who and when did what
46124612
\item Branching and merging of branches helps with making of big changes
4613-
\item Users work on a project in some directory as usually and from time to time commit local changes to stagging (temporal area) and then push them to remote or local repository (directory storing all Git history of particular project, can be anywhere)
4614-
\item Every commit is checkpoint in the history
4615-
\begin{itemize}
4616-
\item Can be tagged (named), e.g. particular released version of software, or project stage
4617-
\item User can compare any two commits or commit and current state
4618-
\end{itemize}
4619-
\item Code can be branched
46204613
\begin{itemize}
46214614
\item When new branch is created, it contains copy of current state
46224615
\item User selects in which branch she/he is working, the branches are diverging, user can commit in every branch independently
46234616
\item Commits in various branches can be compared and branches can be merged again
4624-
\item Key feature of Git --- branches are useful when user starts to work on any big change in the project
4617+
\item Key feature of Git --- branches are useful when user starts to work on any big change in the project (the \enquote{main} part is intact while developers can freely work on major change)
46254618
\end{itemize}
4626-
\item Stagging area serves as local \enquote{container} of changes to be pushed to central Git repository (or to be modified, discarded)
4619+
\item Users work on a project in some directory as usually and from time to time commit local changes to stagging (temporal area) and then push them to remote or local repository (directory storing all Git history of particular project, can be anywhere)
4620+
\item Every commit is checkpoint in the history
46274621
\begin{itemize}
4628-
\item It is very hard to do any change in the central Git repository (e.g. to remove accidentaly pushed file or change description)
4622+
\item Can be tagged (named), e.g. particular released version of software, or project stage
4623+
\item User can compare any two commits or commit and current state
46294624
\end{itemize}
4625+
\item Stagging area serves as local \enquote{container} of changes to be pushed to central Git repository (or to be modified, discarded)
46304626
\item Central repository keeps whole history of the project
46314627
\begin{itemize}
46324628
\item Every user has full copy of the central Git repository --- can be large
4633-
\item Can be placed on some server, network disk, in the local computer,~\ldots
46344629
\end{itemize}
46354630
\item Git was developed by Linus to trace development of Linux kernel, now it is probably the most used version control tool, used also by Microsoft to trace development of Windows :-)
46364631
\end{itemize}
@@ -4641,11 +4636,12 @@ \subsection{Git principle}
46414636
\item \href{https://github.com/}{GitHub} is currently probably the most popular platform to host development of open-source projects, see \href{https://help.github.com/}{documentation}
46424637
\item Probably second most common on-line service providing Git repository is \href{https://about.gitlab.com/}{GitLab}
46434638
\begin{itemize}
4644-
\item User can create an account on GitLab (as on GitHub), or download and install GitLab system on own server
4639+
\item User can create an account on GitLab (as on GitHub), or download and install GitLab system on own server (like \href{https://sorbus.ibot.cas.cz/en/gitlab}{we did})
46454640
\end{itemize}
46464641
\item \href{https://sourceforge.net/}{SourceForge} used to be more popular in the past, still harbours plenty of interesting projects
4642+
\item Others are e.g. \href{https://bitbucket.org/}{Bitbucket}, \href{https://www.codebasehq.com/}{Codebase},~\ldots
46474643
\item For on-line services, many tools are available only for paying customers
4648-
\item All such services provide Git repositories accessible through standard tools (from command line, see further; or from some special application)
4644+
\item All such services provide Git repositories accessible through standard tools (from command line, see further; or from some special application), through web browser
46494645
\begin{itemize}
46504646
\item Exact usage might differ from standard Git, check respective help pages first
46514647
\end{itemize}
@@ -4686,29 +4682,29 @@ \subsection{Git basics}
46864682
46874683
\begin{frame}[fragile]{Working with Git --- start and sending changes}
46884684
\begin{bashcode}
4689-
# Create a new repository for new project (in empty directory)
4690-
git init # No need when cloning from existing repository
46914685
# Create a new central repository (e.g. on a server) in empty directory
46924686
git init --bare
4693-
# Or checkout (make a copy) for another local or remote repository
4687+
# Create a new repository for new project (in empty directory)
4688+
git init # No need when cloning from existing repository
4689+
# If you did not start by cloning, add connection to server
4690+
git remote add origin <location> # Do only once on the beginning
4691+
# <location> can be remote server or local path
4692+
git remote add origin . # For repository within working directory
4693+
# Or checkout (make a copy) of existing local or remote repository
46944694
git clone /path/to/local/repository # Locally mounted repository
46954695
git clone username@host:/path/to/remote/repository # Over SSH
46964696
git clone https://github.com/V-Z/course-linux-command-line-bash-
46974697
scripting-metacentrum.git # Clone from web, e.g. GitHub
46984698
# Add files to trace with Git
46994699
# Ignored files (or patterns) can be listed in .gitignore file
47004700
git add <files> # Or "git add *"
4701-
# Commit changes to prepare then to send to repository
4702-
git commit -m "Message..."
4703-
# If you did not start by cloning, add connection to server
4704-
git remote add origin <location> # Do only once on the beginning
4705-
# <location> can be remote server or local path
47064701
\end{bashcode}
47074702
\end{frame}
47084703
47094704
\begin{frame}[fragile]{Working with Git --- branching and getting changes}
47104705
\begin{bashcode}
4711-
git remote add origin . # For repository within working directory
4706+
# Commit changes to prepare them to send to repository
4707+
git commit -m "Message..."
47124708
# Push changes into the repository (regardless where it is)
47134709
git push origin master # See further for selection of branches
47144710
# Making new branch and switching to it
@@ -4722,12 +4718,12 @@ \subsection{Git basics}
47224718
git push origin <branch>
47234719
# List branches (current is marked by asterisk on the beginning)
47244720
git branch
4725-
# Download news from central server
4726-
git fetch
4721+
# Download news from central server (work of colleagues, etc.)
4722+
git fetch # Downloaded to stagging, not applied yet to local files
47274723
\end{bashcode}
47284724
\end{frame}
47294725
4730-
\begin{frame}[fragile]{Working with Git --- tags, logs and settings}
4726+
\begin{frame}[fragile]{Working with Git --- tags, logs and more}
47314727
\begin{bashcode}
47324728
# Update local repository to the newest version from central repository
47334729
git pull # Fetch and merge remote changes (before commit)
@@ -4749,7 +4745,13 @@ \subsection{Git basics}
47494745
\end{bashcode}
47504746
\end{frame}
47514747
4752-
\begin{frame}[fragile]{Working with Git --- tags, logs and settings}
4748+
\begin{frame}[fragile]{Working with Git --- settings and more}
4749+
\begin{itemize}
4750+
\item Basically repeat in \texttt{git} \texttt{add}, \texttt{commit} and \texttt{push} to get your work to the repository, and \texttt{fetch} and \texttt{pull} to download news from central repository
4751+
\item \texttt{diff} to see local changes
4752+
\item \texttt{log} and \texttt{branch} show history and branches
4753+
\item \texttt{branch} and \texttt{merge} for branching code and merging changes back to master (main) branch
4754+
\end{itemize}
47534755
\begin{bashcode}
47544756
gitk # Graphical interface
47554757
git config color.ui true # Set output to be colored

0 commit comments

Comments
 (0)