Ver la versión documento (.md) en GitHub
Nota:
El objetivo de este documento se enfoca en la creación y publicación de un post formato blog. Se mostrará paso a paso, desde la escritura en Rmarkdown hasta publicación en GitHub.
RMarkdown y GitHub utilizan la sintaxis de Markdown para reproducir facilmente formatos de escrituras (html en este caso). Para escribir un documento bien estructurado es fundamental conocer los elementos básicos para crear un texto: títulos, subtítulos, listas, letras en cursivas o en negritas, citas, etc. Por ejemplo en RMarkdown, para diferenciar un parafo de otro se deben separar por una lina de código vacía.
A continuación se presenta algunas de las principales sintaxis y en la linea siguiente la salida o (render) correspondiente:
# Ejemplo de título grande
### Ejemplo de un sub título
*cursiva* y *negrita*
cursiva y negrita
`formato código`
formato código
superindice^2^ y subindice~2~
superindice2 y subindice2
~~tachado~~
tachado
* _ \
Poner signos: \* \_ \\
Poner signos: * _ \
--
–
---
Ecuación en linea $A=\pi*r^2$
Ecuación en linea \(A=\pi*r^2\)
$$A=\pi*r^2$$
\[A=\pi*r^2\]
Saltar a [Ejemplo de título grande]
Saltar a Ejemplo de título grande
> Cita
Cita
<https://psaid.shinyapps.io/AInsigne/>
https://psaid.shinyapps.io/AInsigne/
[Link a AInsigne](https://psaid.shinyapps.io/AInsigne/)
* item de lista * otro item + sub item - sub sub item
* otro item
***
Video
Las sintaxis presentadas son algunas que se pueden utilizar en Rmarkdown, pero hay otras que funcionan en GitHub:
(Las cajas de check funcionan en los archivos .md)
git init creates a new Git repository.git status inspects the contents of the working directory and staging area.git add adds files from the working directory to the staging area.git diff shows the difference between the working directory and the staging area.git commit permanently stores file changes from the staging area in the repository.git log shows a list of all previous commits.https://github.com/DGIIMUnderground/DGIIM1/blob/master/guias/github.md https://github.com/JJ/aprende-git/blob/master/texto/uso_basico.md
To better understand git reset commit_SHA, notice the diagram on the right. Each circle represents a commit.
Before reset:
HEAD is at the most recent commitAfter resetting:
HEAD goes to a previously made commit of your choiceYou have in essence rewound the project’s history
git checkout HEAD filname: Discards changes in the working directory.git reset HEAD filname: Unstages file changes in the staging area.git reset commit_SHA: Resets to a previous commit in your commit history.
git branch:
Git branching allows users to experiment with different versions of a project by checking out separate branches to work on. The following commands are useful in the Git branch workflow.
git branch: Lists all a Git project’s branches.git branch branch_name: Creates a new branch.git checkout branch_name: Used to switch from one branch to another.git merge branch_name: Used to join file changes from one branch to another.git branch -d branch_name: Deletes the branch specified.Para usar GitHub se debe crear una cuenta en https://github.com/.
Para instalar Git visitar git-scm.com/downloads.
Luego de instalar Git se debe configurar el nombre de usuario y email.
Configurar Git
git config --global user.name "Nombre que quieras mostrar"
git config --global user.email "correo@email.com"
Ver https://help.github.com/en/articles/set-up-git para mas información.
Para crear un repositorio en Git se suele usar las linas de comandos, algunas son:
Lineas de comandos:
lspwdcdcd ..mkdir: crea un directoriotouch: crea un archivoAhora usémoslas para crear un repositorio:
mkdir git_practice to make a new directory to practice.cd git_practice to make the new directory your working directory.git init to turn the current, empty directory into a fresh Git repository.echo "Hello Git and GitHub" >> README.txt to create a new README file (more on this later) with some sample text.git add README.txt to add the new file to the Git staging area.git commit -m "First commit" to make your first commit with the new README file.A remote is a Git repository that lives outside your Git project folder. Remotes can live on the web, on a shared network or even in a separate folder on your local computer. The Git Collaborative Workflow are steps that enable smooth project development when multiple collaborators are working on the same Git project. We also learned the following commands
git clone: Creates a local copy of a remote.git remote -v: Lists a Git project’s remotes.git fetch: Fetches work from the remote into the local copy.git merge origin/master: Merges origin/master into your local branch.git push origin <branch_name>: Pushes a local branch to the origin remote.Git projects are usually managed on Github, a website that hosts Git projects for millions of users. With Github you can access your projects from anywhere in the world by using the basic workflow you learned here.
Para subir este documento a github: en yalm puse
output: github_documentpara que cree un archivo (.md) aparte del (.Rmd). en la consola de GIT BACH me dirigí a la carpeta local que contiene este archivo, luego reviségit status, añadí los archivos congit add .(el punto es para subir todos los documentos q cambiaron, el .Rmd y .md, y los subí para comparar las salidas), luego un commitgit commit -m "formato github(por ejemplo)"y finalmente un push,git push. Ahora se puede ver el documento en la pagina de GitHub con los render correspondientes de las sintaxis Markdown (el .md).
Ahora, cómo publicar un documento tipo blog hosteando la página con GitHub Pages
Fuente: (https://resources.github.com/whitepapers/github-and-rstudio/)
(En RStudio ir a Tools> Global options> Git y en el PATH debe estar git.exe C:/Program Files/Git/bin/git.exe )
Commit and push the changes to GitHub
After you have created the R Markdown document and finished making your changes, it is time to commit them.
Git tab in the upper right pane.(bien, ahora me aparece , puse guardar los cambios para que aparezca para hacer commit )Commit. (ok)Commit. (ok)Pull button to fetch any remote changes. (ok)Push button to push your changes to the remote repository. (ok)Olvidé el archivo .md, repito los pasos anteriores para añdirlo.
Create local branches with Git
Let’s make a couple of more changes in your project using the steps of GitHub Flow. As RStudio currently does not support local branches very well, we will use Git from the command-line in RStudio.
Terminal tab in the lower left pane. The Terminal tab is next to the Console tab.git branch new-branchgit statusgit checkout new-branchgit statusMake local changes with Git
Let’s generate the HTML output in a separate directory called docs. To do this we add a function in the heading of the R Markdown document to “knit” the output in the desired output directory.
apuntes_git_rmarkdown.Rmd) and add the following lines in the heading under the title field:knit: (function(input_file, encoding) {
out_dir <- 'docs';
rmarkdown::render(input_file,
encoding=encoding,
output_file=file.path(dirname(input_file), out_dir, 'index.html'))})(En el yalm tuve q sacar output: github_document)
(También tuve que crear una carpeta llamada docs para que guardara el archivo index.htlm ya que me salia error)
File, Save to save the changes.Commit local changes with Git
After you have created the HTML output, it is time to commit the changes.
git status allows us to see the status of the files on our branch at any given time. Your file is listed under the heading Untracked files: git statusgit add .Changes to be committed. This tells us that the file is in the staging area. It also indicates this is a new file: git status<COMMIT-MESSAGE> with a log message describing the changes, for example Knit output to a docs folder. A commit tells Git to collect all of the files in the staging area and store them to version control as a single unit of work: git commit -m "<COMMIT-MESSAGE>"git log --online (me salió error)git diff --stat --summary master..<BRANCH-NAME>Open a pull request on GitHub
Now that you have made some local commits, it is time to send your changes to the remote copy of your repository on GitHub and create a Pull Request.
git push -u origin <BRANCH-NAME>Merge your pull request on GitHub
Since this is your repository, you probably don’t have anyone to collaborate with (yet). Go ahead and merge your Pull Request now.
Pull Request that you just opened.Merge Pull Request button.Confirm Merge.This tutorial is going to use GitHub Pages to publish the HTML output. To initialize GitHub Pages we need to perform a few more steps:
Settings tab.GitHub Pages section.Source, select master branch /docs folder.Save to save the changes.Note: GitHub Pages sites are always public when hosted on GitHub.com. If you want to share a site with a select number of people you can use Jekyll Auth. On GitHub Enterprise users need to authenticate to access GitHub Pages sites when private mode is enabled.
Update local repository
After you merge your Pull Request, you will need to update your local copy of the repository.
git checkout mastergit pullgit branch -D <BRANCH-NAME>git log --oneline --graph --allYou can also view the history of your commits in RStudio. Click Commit in the Git pane to open the Review Changes panel and then click History.