Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
apostila-git
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pet-estatistica
apostila-git
Commits
622f375b
Commit
622f375b
authored
9 years ago
by
Knight Rider
Browse files
Options
Downloads
Patches
Plain Diff
Revisa e adiciona o cap08:
- Muda de Rmd para Rnw. - Define e usa um ambiente flutuante para rotinas.
parent
6ba2c201
Branches
Branches containing commit
No related tags found
1 merge request
!56
Issue#68
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
apostila_git.tex
+94
-2
94 additions, 2 deletions
apostila_git.tex
cap08/cap08_er.Rnw
+81
-124
81 additions, 124 deletions
cap08/cap08_er.Rnw
with
175 additions
and
126 deletions
apostila_git.tex
+
94
−
2
View file @
622f375b
...
...
@@ -47,7 +47,7 @@
}{}
%-----------------------------------------------------------------------
% knitr.
% knitr
quando faz render em Rmd para gerar tex
.
\usepackage
{
color
}
\usepackage
{
fancyvrb
}
...
...
@@ -73,6 +73,58 @@
\newcommand
{
\ErrorTok
}
[1]
{
\textbf
{{
#1
}}}
\newcommand
{
\NormalTok
}
[1]
{{
#1
}}
%-----------------------------------------------------------------------
% knitr quando faz knit em Rnw para gerar tex
% \usepackage[]{graphicx}\usepackage[]{color}
% \makeatletter
% \def\maxwidth{ %
% \ifdim\Gin@nat@width>\linewidth
% \linewidth
% \else
% \Gin@nat@width
% \fi
% }
% \makeatother
\definecolor
{
fgcolor
}{
rgb
}{
0.345, 0.345, 0.345
}
\newcommand
{
\hlnum
}
[1]
{
\textcolor
[rgb]
{
0.686,0.059,0.569
}{
#1
}}
%
\newcommand
{
\hlstr
}
[1]
{
\textcolor
[rgb]
{
0.192,0.494,0.8
}{
#1
}}
%
\newcommand
{
\hlcom
}
[1]
{
\textcolor
[rgb]
{
0.678,0.584,0.686
}{
\textit
{
#1
}}}
%
\newcommand
{
\hlopt
}
[1]
{
\textcolor
[rgb]
{
0,0,0
}{
#1
}}
%
\newcommand
{
\hlstd
}
[1]
{
\textcolor
[rgb]
{
0.345,0.345,0.345
}{
#1
}}
%
\newcommand
{
\hlkwa
}
[1]
{
\textcolor
[rgb]
{
0.161,0.373,0.58
}{
\textbf
{
#1
}}}
%
\newcommand
{
\hlkwb
}
[1]
{
\textcolor
[rgb]
{
0.69,0.353,0.396
}{
#1
}}
%
\newcommand
{
\hlkwc
}
[1]
{
\textcolor
[rgb]
{
0.333,0.667,0.333
}{
#1
}}
%
\newcommand
{
\hlkwd
}
[1]
{
\textcolor
[rgb]
{
0.737,0.353,0.396
}{
\textbf
{
#1
}}}
%
\usepackage
{
framed
}
\makeatletter
\newenvironment
{
kframe
}{
%
\def\at
@end@of@kframe
{}
%
\ifinner\ifhmode
%
\def\at
@end@of@kframe
{
\end{minipage}
}
%
\begin{minipage}
{
\columnwidth
}
%
\fi\fi
%
\def\FrameCommand
##1
{
\hskip\@
totalleftmargin
\hskip
-
\fboxsep
\colorbox
{
shadecolor
}{
##1
}
\hskip
-
\fboxsep
% There is no \\@totalrightmargin, so:
\hskip
-
\linewidth
\hskip
-
\@
totalleftmargin
\hskip\columnwidth
}
%
\MakeFramed
{
\advance\hsize
-
\width
\@
totalleftmargin
\z
@
\linewidth\hsize
\@
setminipage
}}
%
{
\par\unskip\endMakeFramed
%
\at
@end@of@kframe
}
\makeatother
\definecolor
{
shadecolor
}{
rgb
}{
.97, .97, .97
}
\definecolor
{
messagecolor
}{
rgb
}{
0, 0, 0
}
\definecolor
{
warningcolor
}{
rgb
}{
1, 0, 1
}
\definecolor
{
errorcolor
}{
rgb
}{
1, 0, 0
}
\newenvironment
{
knitrout
}{}{}
% an empty environment to be redefined in TeX
\usepackage
{
alltt
}
%-----------------------------------------------------------------------
\usepackage
{
graphicx
}
...
...
@@ -144,7 +196,6 @@
\date
{
2015
}
\predate
{}
\postdate
{}
\usepackage
{
tikz
}
% Color used in the title page.
\definecolor
[named]
{
color01
}{
rgb
}{
.2,.4,.6
}
...
...
@@ -153,6 +204,44 @@
\usepackage
{
wallpaper
}
\usepackage
{
menukeys
}
\usepackage
{
pdflscape
}
\usepackage
{
multicol
}
\usepackage
{
cleveref
}
\usepackage
[labelsep=colon]
{
caption
}
%-----------------------------------------------------------------------
% Define ambiente para os Exemplos de Rotina.
\usepackage
{
float
}
% Controla e define objetos flutuantes.
\usepackage
{
tocloft
}
% Controla lista de objetos flutuantes.
% Nome dessa lista.
\newcommand
{
\listofprogramname
}{
Rotinas
}
% Configura os arquivos auxiliares para fazer a lista.
\newlistof
{
program
}{
lol
}{
\listofprogramname
}
\makeatletter
\newcommand\floatc
@simple[2]
{{
\@
fs@cfont #1 #2
}
\par
}
\newcommand\fs
@simple
{
\def\@
fs@cfont
{}
\let\@
fs@capt
\floatc
@simple
\def\@
fs@pre
{}
%
\def\@
fs@post
{}
%
\def\@
fs@mid
{
\kern
8pt
}
%
\let\@
fs@iftopcapt
\iftrue
}
\makeatother
\floatstyle
{
simple
}
\newfloat
{
program
}{
thp
}{
lol
}
[chapter]
% Define ambiente
\floatname
{
program
}{
Rotina
}
% Rótulo na legenda.
%% Aparencia do sumário de rotinas
\renewcommand*\cftprogrampresnum
{
Rotina~
}
\settowidth
{
\cftprogramnumwidth
}{
\cftprogrampresnum
}
\setlength
{
\cftprogramindent
}{
0cm
}
\renewcommand
{
\cftprogramaftersnumb
}{
\qquad
}
\renewcommand
{
\cftprogramaftersnum
}{
:
}
%-----------------------------------------------------------------------
...
...
@@ -265,6 +354,9 @@
% \input{cap08.tex}
% \input{cap09.tex}
\addcontentsline
{
toc
}{
chapter
}{
Apêndice
}
\input
{
./cap08/cap08
_
er.tex
}
\end{document}
%-----------------------------------------------------------------------
\ No newline at end of file
This diff is collapsed.
Click to expand it.
cap08/cap08_er.R
md
→
cap08/cap08_er.R
nw
+
81
−
124
View file @
622f375b
---
title: "Exemplos de Rotina"
author: "PET Estatística UFPR"
graphics: yes
header-includes:
\usepackage{multicol}
\usepackage{cleveref}
output:
pdf_document:
template: ../template.tex
highlight: default
toc: true
toc_depth: 2
keep_tex: true
number_sections: true
---
\newpage
\appendix
\chapter{Exemplos de
R
otinas}
\chapter{Exemplos de
r
otinas}
Neste apêndice são descritas brevemente algumas das rotinas mais usuais
em projetos Git. A maioria dos exemplos estão detalhados na apostila e
foram resumidos nesta coletânea. Abaixo temos a lista de rotinas aqui
presentes:
\begin{multicols}{2}
\footnotesize
\begin{description}
\item[Configure usuário e e-mail,] pág. \pageref{routine1}
\item[Inicie um projeto git local,] pág. \pageref{routine2}
\item[Trabalhe com ramos,] pág. \pageref{routine3}
\item[Visualize diferenças,] pág. \pageref{routine4}
\item[Resolva conflitos de \textit{merge},] pág. \pageref{routine5}
\item[Visualize seu projeto,] pág. \pageref{routine6}
\item[Volte versões anteriores,] pág. \pageref{routine7}
\item[Reescreva \textit{commits},] pág. \pageref{routine8}
\item[Adicione chaves públicas,] pág. \pageref{routine9}
\item[Trabalhe remotamente,] pág. \pageref{routine10}
\item[Manipule ramos remotos,] pág. \pageref{routine11}
\item[Adicione local remoto,] pág. \pageref{routine12}
\end{description}
\end{multicols}
\pagebreak
<!-- ------------------------------------------- -->
\hlabel{routine1}
\routine{Configure usuário e e-mail}
```{r, engine='bash', echo=TRUE, eval=FALSE}
presentes.
\listofprogram
\begin{program}[H]
\caption{Configure usuário e e-mail.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## Configurando localmente
## - válido para o repositório atual
git config user.name "Name Lastname"
...
...
@@ -62,15 +26,14 @@ git config --global user.email "namelastname@servidor"
## Obs.: As configurações locais se sobrepõem as
## globais, quando as duas forem avaliadas.
@
```
<!-- ------------------------------------------- -->
\hlabel{routine2}
\routine{Inicie um projeto Git local}
```{r, engine='bash', echo=TRUE, eval=FALSE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Inicie um projeto Git local.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## Em um diretório que deseja-se versionar
## Inicia o versionamento Git
...
...
@@ -88,15 +51,14 @@ git commit -m "Inicia repositório"
## Verifica o histórico de versões
git log
@
```
<!-- ------------------------------------------- -->
\hlabel{routine3}
\routine{Trabalhe com ramos}
```{r, engine='bash', echo=TRUE, eval=FALSE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Trabalhe com ramos.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## Verifica os ramos existentes
git branch
...
...
@@ -125,14 +87,14 @@ git merge bugfix
## Deleta o ramo responsável pela correção do bug
git branch -d bugfix
```
<!-- ------------------------------------------- -->
\hlabel{routine4}
\routine{Visualize diferenças}
@
```{r, engine='bash', echo=TRUE, eval=FALSE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Visualize diferenças.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## -------------------------------------------
## Diferenças não commitadas
...
...
@@ -165,14 +127,14 @@ git diff master feature1
## visualizar diferenças, use difftool no lugar de
## diff, ver cap. 06
```
<!-- ------------------------------------------- -->
\hlabel{routine5}
\routine{Resolva conflitos de merge}
@
```{r, engine='bash', eval=FALSE, echo=TRUE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Resolva conflitos de merge.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## Incorpora modificações realizadas no ramo feature
git merge feature
...
...
@@ -182,14 +144,14 @@ git merge feature
## Finaliza merge com o commit:
git commit -a -m "Merge do ramo feature"
```
@
<!-- ------------------------------------------- -->
\hlabel{routine6}
\routine{Visualize seu projeto}
```{r, engine='bash', eval=FALSE, echo=TRUE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Visualize seu projeto.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## Histórico de registros
git log
...
...
@@ -202,15 +164,14 @@ git reflog
## Histórico de registro via interface gráfica padrão
gitk
@
```
<!-- ------------------------------------------- -->
\hlabel{routine7}
\routine{Volte versões anteriores}
```{r, engine='bash', echo=TRUE, eval=FALSE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Volte versões anteriores.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## Verifica o histórico de versões do repositório
## - Guarde o SHA1 ID do registro desejado: ec3650c8
git log --oneline
...
...
@@ -245,14 +206,14 @@ git checkout -b ramo_teste
## Obs.: O ramo provisório é removido assim que se
## fizer um checkout para qualquer outro ramo
```
<!-- ------------------------------------------- -->
\hlabel{routine8}
\routine{Reescreva commits}
@
```{r, engine='bash', echo=TRUE, eval=FALSE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Reescreva commits.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## Verifica o histórico de versões do repositório
git log --oneline
...
...
@@ -265,15 +226,14 @@ git commit --amend -m "Correção de Commit"
## Obs2.: Reescreve a história do repositório, não
## é recomendável reescrever a linha do tempo quando
## se está em um projeto colaborativo remoto.
@
```
<!-- ------------------------------------------- -->
\hlabel{routine9}
\routine{Adicione chaves públicas}
```{r, engine='bash', echo=TRUE, eval=FALSE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Cria chaves públicas.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## Cria uma chave pública.
ssh-keygen -t rsa -C "namelastname@servidor"
...
...
@@ -291,15 +251,14 @@ ssh -T endereço ## endereço = git@github.com, ...
## Obs.: Todos os comandos ssh são provinientes do
## pacote de função ssh para shell, portanto para
## utilizar instale este pacote.
@
```
<!-- ------------------------------------------- -->
\hlabel{routine10}
\routine{Trabalhe remotamente}
```{r, engine='bash', echo=TRUE, eval=FALSE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Trabalhe remotamente.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## Clona um projeto remoto:
## e.g. git@github.com:pet-estatistica/apostila-git.git
git clone endereço:namespace/project.git
...
...
@@ -318,15 +277,14 @@ git push origin
## Traz estado do repositório remoto
git pull origin
@
```
<!-- ------------------------------------------- -->
\hlabel{routine11}
\routine{Manipule ramos remotos}
```{r, engine='bash', echo=TRUE, eval=FALSE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Manipule ramos remotos.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## -------------------------------------------
## Realizando contribuições em um ramo remoto
...
...
@@ -383,15 +341,14 @@ git push origin master
git branch -d bugfix ## Local
git push :bugfix ## Remoto
```
<!-- \routine{Incorporar o remoto ao local} -->
<!-- ------------------------------------------- -->
\hlabel{routine12}
\routine{Adicione local remoto}
@
```{r, engine='bash', eval=FALSE, echo=TRUE}
%%----------------------------------------------------------------------
\begin{program}[H]
\caption{Adicione endereço remoto.}
\end{program}
<<engine="bash", echo=TRUE, eval=FALSE>>=
## Lista os servidores remotos, com endereço
git remote -v
...
...
@@ -421,4 +378,4 @@ git remote set-url origin --push --add endereço_remoto
## Envia as contribuições para os locais remotos
git push origin
```
\ No newline at end of file
@
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment