You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: presentation/linux_bash_metacentrum_course.tex
+29-27Lines changed: 29 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -4601,7 +4601,7 @@ \subsection{Git principle}
4601
4601
4602
4602
\begin{frame}[allowframebreaks]{Git and version control}
4603
4603
\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
4605
4605
\item Older (nowadays not so common) version controlling systems is Subversion (SVN), there are many more (Bazaar, Mercurial,~\ldots)
4606
4606
\item Probably the best textbook for Git is \href{https://git-scm.com/book/en/v2}{Chacon's Pro Git}
\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
4611
4611
\item It is possible to trace who and when did what
4612
4612
\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
4620
4613
\begin{itemize}
4621
4614
\item When new branch is created, it contains copy of current state
4622
4615
\item User selects in which branch she/he is working, the branches are diverging, user can commit in every branch independently
4623
4616
\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)
4625
4618
\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
4627
4621
\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
4629
4624
\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)
4630
4626
\item Central repository keeps whole history of the project
4631
4627
\begin{itemize}
4632
4628
\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
4634
4629
\end{itemize}
4635
4630
\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 :-)
\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}
4642
4637
\item Probably second most common on-line service providing Git repository is \href{https://about.gitlab.com/}{GitLab}
4643
4638
\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})
4645
4640
\end{itemize}
4646
4641
\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
4647
4643
\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
4649
4645
\begin{itemize}
4650
4646
\item Exact usage might differ from standard Git, check respective help pages first
4651
4647
\end{itemize}
@@ -4686,29 +4682,29 @@ \subsection{Git basics}
4686
4682
4687
4683
\begin{frame}[fragile]{Working with Git --- start and sending changes}
4688
4684
\begin{bashcode}
4689
-
# Create a new repository for new project (in empty directory)
4690
-
git init # No need when cloning from existing repository
4691
4685
# Create a new central repository (e.g. on a server) in empty directory
4692
4686
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
scripting-metacentrum.git # Clone from web, e.g. GitHub
4698
4698
# Add files to trace with Git
4699
4699
# Ignored files (or patterns) can be listed in .gitignore file
4700
4700
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
4706
4701
\end{bashcode}
4707
4702
\end{frame}
4708
4703
4709
4704
\begin{frame}[fragile]{Working with Git --- branching and getting changes}
4710
4705
\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..."
4712
4708
# Push changes into the repository (regardless where it is)
4713
4709
git push origin master # See further for selection of branches
4714
4710
# Making new branch and switching to it
@@ -4722,12 +4718,12 @@ \subsection{Git basics}
4722
4718
git push origin <branch>
4723
4719
# List branches (current is marked by asterisk on the beginning)
4724
4720
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
4727
4723
\end{bashcode}
4728
4724
\end{frame}
4729
4725
4730
-
\begin{frame}[fragile]{Working with Git --- tags, logs and settings}
4726
+
\begin{frame}[fragile]{Working with Git --- tags, logs and more}
4731
4727
\begin{bashcode}
4732
4728
# Update local repository to the newest version from central repository
4733
4729
git pull # Fetch and merge remote changes (before commit)
@@ -4749,7 +4745,13 @@ \subsection{Git basics}
4749
4745
\end{bashcode}
4750
4746
\end{frame}
4751
4747
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}
4753
4755
\begin{bashcode}
4754
4756
gitk # Graphical interface
4755
4757
git config color.ui true # Set output to be colored
0 commit comments