Added information about workflows
This commit is contained in:
parent
d37d470c95
commit
0d9e1fee1d
@ -633,6 +633,34 @@ What does \texttt{git pull} do? It's a combination of two Git commands: \texttt{
|
||||
|
||||
\chapter{Next Steps}
|
||||
|
||||
\section{Workflows}
|
||||
|
||||
Git makes it easy to be methodical in your work. It's therefore useful to have workflows in mind when working with Git, especially when you are using remote repositories.
|
||||
|
||||
You have a choice of two basic approaches: create your local repository first, or create your remote repository first. Both have their advantages.
|
||||
|
||||
\subsection{Remote Repository First}
|
||||
|
||||
In this approach, you create your remote repository first, and then clone it using this command:
|
||||
|
||||
\input{include/clone}
|
||||
|
||||
By default, your remote repository will be named \texttt{origin}, but you can change this by using the \texttt{--origin} (or the short \texttt{-o} version) option:
|
||||
|
||||
\input{include/cloneorigin}
|
||||
|
||||
The main advantage of this approach is that you can begin pushing your work to your remote repository immediately, which may be important if you have people who are waiting to see it or collaborate with you on it. If you don't start pushing right away, at least they know where your work will eventually be.
|
||||
|
||||
\subsection{Local Repository First}
|
||||
|
||||
In this approach, you create your local directory first using \texttt{git init}. You then create a remote repository when it is convenient to you, and add that remote using this command:
|
||||
|
||||
\input{include/gitadd}
|
||||
|
||||
This approach has numerous advantages. You can begin making commits at once, and then push everything to your remote only when you are ready. This also allows you to experiment with a number of different projects and then make only those public that you feel are high enough quality to share with the world.
|
||||
|
||||
This approach has one main advantage, however. Because your work exists only on your local machine, if something happens to your computer, you will lose all of your work. This can be mitigated by making regular backups.
|
||||
|
||||
\section{README.md}
|
||||
|
||||
If you pull or clone a remote repository, you may notice files like \texttt{.gitignore} and \texttt{README.md}. The first tells Git which files to \textit{not} track. (And yes, you will want to make use of this at some point.) The second is a text document written in Markdown (hence the \texttt{.md} file extension) which appears on the front page of the online repo.
|
||||
|
4
include/cloneorigin.tex
Normal file
4
include/cloneorigin.tex
Normal file
@ -0,0 +1,4 @@
|
||||
\begin{Verbatim}[]
|
||||
$ git clone <URL of remote repo> --option <origin name>
|
||||
$ git clone <URL of remote repo> -o <origin name>
|
||||
\end{Verbatim}
|
3
include/gitadd.tex
Normal file
3
include/gitadd.tex
Normal file
@ -0,0 +1,3 @@
|
||||
\begin{Verbatim}[]
|
||||
$ git remote add <remote name> <URL of remote repository>
|
||||
\end{Verbatim}
|
3
include/gitinit.tex
Normal file
3
include/gitinit.tex
Normal file
@ -0,0 +1,3 @@
|
||||
\begin{Verbatim}[]
|
||||
$ git init
|
||||
\end{Verbatim}
|
Loading…
Reference in New Issue
Block a user