0% found this document useful (0 votes)
38 views11 pages

Git y Github

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views11 pages

Git y Github

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Módulo 1

Resumen: Primeros pasos con Git y GitHub


● Git es un versátil sistema de control de versiones utilizado para realizar un
seguimiento de los cambios en el código y colaborar con otras personas en
proyectos de software.
● Al ser un sistema de control de versiones distribuido, Git le permite revertir al estado
anterior o revisar el historial del proyecto.
● GitHub es uno de los servicios alojados en la web más populares para repositorios
Git.
● Los repositorios son estructuras de almacenamiento que guardan documentos,
incluido el código fuente de las aplicaciones, y permiten a los colaboradores realizar
un seguimiento y mantener el control de las versiones.
● Modelo de repositorio Git
○ Centrado principalmente en el seguimiento del código fuente durante el
desarrollo.
○ Contiene elementos para la coordinación entre programadores, el
seguimiento de los cambios y el soporte de flujos de trabajo no lineales.
● Los repositorios son estructuras de almacenamiento que pueden contener código,
realizar un seguimiento de las incidencias y permitirle colaborar con otras personas.
● GitHub permite crear repositorios, editar archivos utilizando la interfaz web, confirmar
los cambios en el archivo, subir los archivos, y mucho más.

Resumen: Ramas con GitHub


● Una rama es una instantánea de su repositorio en la que puede realizar cambios.
● En la rama hija, puede construir, hacer ediciones, probar los cambios y luego
fusionarlos con la rama principal.
● Para asegurarse de que los cambios realizados por un miembro no impiden o
afectan al flujo de trabajo de otros miembros, se pueden crear múltiples ramas y
fusionarlas con la rama principal.
● Una pull request es una forma de notificar a otros miembros del equipo los cambios
y ediciones realizados en la rama principal.
Glosario: Fundamentos de Git y GitHub

Term Definition

A separate line of development that allows to work on features or fixes


Branch
independently.

Clone A local copy of the remote Git repository on the computer.

A snapshot of the project's current state at a specific point in time, along


Commit
with a description of the changes made.

Continuous The automated movement of software through the software development


delivery (CD) lifecycle.

Continuous A software development process in which developers integrate new code


integration (CI) into the code base at least once a day.

A system that keeps track of changes to code, regardless of where it is


Distributed stored. Multiple users work on the same codebase or repository, mirroring
version control the codebase on their computers if needed, while the distributed version
system (DVCS) control software helps manage synchronization amongst the various
codebase mirrors.

Fork A copy of a repository into your GitHub account.

GitHub A web-hosted service for the Git repository.

A branch stores all files in GitHub. Branches are used to isolate changes to
GitHub
code. When the changes are complete, they can be merged back into the
branches
main branch.
A complete DevOps platform delivered as a single application. It provides
GitLab
access to Git repositories, controlled by source code management.

Free and open-source software distributed under the GNU General Public
Git License. It is a distributed version control system that allows users to have
a copy of their own project on their computer anywhere in the world.

A process to combine changes from one branch to another, typically


Merge
merging a feature branch into the main branch.

A process used to request that someone review and approve your changes
Pull request
before they become final.

A data structure for storing documents, including application source code.


Repository
It contains the project folders that are set up for version control.

SSH Protocol A method for secure remote login from one computer to another.

A system that allows you to keep track of changes to your documents. This
Version control process allows you to recover older versions of the documents if any
mistakes are made.

Working A directory in your file system that contains files and subdirectories on your
directory computer that are associated with a Git repository.
Módulo 2

Comandos de Git
git add
Description: It adds changes to the staging area. This command stages the changes made to the files
and prepares them for the next commit.
Syntax:
git add <filename.txt> (to add a specific file)
git add . (to add all the files that are new or changed in the current directory)
git add -A (to add all changes in the entire working tree, from the root of the repository, regardless of
where you are in the directory structure)

git reset
Description: It resets changes in the working directory. When used with –hard HEAD, this command
discards all changes made to the working directory and staging area and resets the repository to the
last commit (HEAD).
Syntax:
git reset
git reset –hard HEAD

git branch
Description: It lists, creates, or deletes branches in a repository. To delete the branch, first check out
the branch using git checkout and then run the command to delete the branch locally.
Syntax:
git branch (to list branches)
git branch <new-branch> (to create a new branch)
git branch -d <branch-name> (to delete a branch)

git checkout main


Description: It switches to the "main" branch. This will switch your current branch to "main."
Syntax: git checkout main

git clone
Description: It copies a repository from a remote source to your local machine. This will create a copy
of the repository in your current working directory.
Syntax: git clone <repository URL>

git pull
Description: It fetches changes from a remote repository and merges them into your local branch.
First, switch to the branch that you want to merge changes into by running the git checkout command.
Then, run the git pull command, which will fetch the changes from the main branch of the origin
remote repository and merge them into your current branch.
Syntax: git pull origin main

git push
Description: It uploads local repository content to a remote repository. Make sure you are on the
branch that you want to push by running the git checkout command first, then push the branch to the
remote repository.
Syntax: git push origin <branch-name>
git version
Description: It displays the current Git version installed on your system.
Syntax: git version

git diff
Description: It shows changes between commits, commit and working tree, etc. It also compares the
branches.
Syntax:
git diff (shows the difference between the working directory and the last commit)
git diff HEAD~1 HEAD (shows the difference between the last and second-last commits)
git diff <branch-1> <branch-2> (compares the specified branches)

git revert
Description: It reverts a commit by applying a new commit. This will create a new commit that undoes
the changes made by the last commit.
Syntax: git revert HEAD

git config –global user.email <Your GitHub Email>


Description: It sets a global email configuration for Git. This needs to be executed before doing a
commit to authenticate the user's email ID.
Syntax: git config –global user.email <Your GitHub Email>

git config –global user.name <Your GitHub Username>


Description: It sets a global username configuration for Git. This needs to be executed before doing a
commit to authenticate users' username.
Syntax: git config –global user.name <Your GitHub Username>

git remote
Description: It lists the names of all remote repositories associated with your local repository.
Syntax: git remote

git remote -v
Description: It lists all remote repositories that your local Git repository is connected to, along with the
URLs associated with those remote repositories.
Syntax: git remote -v

git remote add origin <URL>


Description: It adds a remote repository named "origin" with the specified URL.
Syntax: git remote add origin <URL>

git remote rename


Description: The git remote rename command is followed by the name of the remote repository
(origin) you want to rename and the new name (upstream) you want to give it. This will rename the
"origin" remote repository to "upstream."
Syntax: git remote rename origin upstream

git remote rm <name>


Description: It removes a remote repository with the specified name.
Syntax: git remote rm origin
git format-patch
Description: It generates patches for email submission. These patches can be used for submitting
changes via email or for sharing them with others.
Syntax: git format-patch HEAD~3 (creates patches for the last three commits)

git request-pull
Description: It generates a summary of pending changes for an email request. It helps communicate
the changes made in a branch or fork to the upstream repository maintainer.
Syntax: git request-pull origin/main <myfork or branch_name>

git send-email
Description: It sends a collection of patches as emails. It allows you to send multiple patch files to
recipients via email. Please make sure to set the email address and name using the git config
command so that the email client knows the sender's information when sending the emails.
Syntax: git send-email *.patch

git am
Description: It applies patches to the repository. It takes a patch file as input and applies the changes
specified in the patch file to the repository.
Syntax: git am <patchfile.patch>

git daemon
Description: It exposes repositories via the Git:// protocol. The Git protocol is a lightweight protocol
designed for efficient communication between Git clients and servers.
Syntax: git daemon –base-path=/path/to/repositories

git instaweb
Description: It instantly launches a web server to browse repositories. It provides a simplified way to
view repository contents through a web interface without the need for configuring a full web server.
Syntax: git instaweb –httpd=webrick

git rerere
Description: It reuses recorded resolution of previously resolved merge conflicts. Please note that the
rerere.enabled configuration option needs to be set to "true" (git config –global rerere.enabled true) for
git rerere to work. Additionally, note that git rerere only applies to conflicts that have been resolved
using the same branch and commit.
Syntax: git rerere

Flujo de trabajo con ramas utilizando comandos git


1. Listar ramas con el comando git branch.
2. Crear la rama PATCH-1-ADDING-HEADERS utilizando el comando git branch
PATCH-1-ADDING-HEADERS.
3. Cambiar a la nueva rama utilizando el comando git checkout
PATCH-1-ADDING-HEADERS.
4. Realizar y establecer los cambios utilizando los comandos git status, git add
index.html, git commit -m.
5. Fusionar PATCH-1-ADDING-HEADERS con la rama principal usando git checkout
main y git merge PATCH-1-ADDING-HEADERS.
6. Empujar la rama principal al repositorio remoto usando git push -u origin main.
Flujo de trabajo con Fork
1. En primer lugar, se crea una bifurcación de un proyecto anterior que, a continuación,
se convierte en el origen.
2. El desarrollador puede crear clones en las máquinas locales, hacer cambios.
3. A continuación, usar git push para devolver la rama principal actualizada al origen
mediante la creación de solicitudes de incorporación de cambios.
4. Los responsables del mantenimiento inicial del proyecto revisan los cambios y, a
continuación, los fusionan si no hay conflictos.
Una cosa a tener en cuenta sobre el comando git merge es que permite tomar líneas de
desarrollo independientes en las ramas de git e integrarlas en una sola rama.

Flujo de trabajo con Clone


1. La clonación entra en escena una vez que has bifurcado (fork) tu repositorio y ahora
se ha convertido en el origen.
2. Luego, usa el origen para crear una copia idéntica del repositorio remoto con el
comando git clone que el desarrollador puede usar en su computadora.
3. A continuación, el nuevo desarrollador crea una nueva rama (branch), realiza los
cambios y los guarda mediante las operaciones de add y commit.
4. Después de eso, llevan la nueva rama al origen (push) para que revisen los
cambios. Un revisor o encargado del mantenimiento usa el comando git fetch o git
pull para obtener la copia más reciente del repositorio y el comando git diff para
ayudar a identificar y comparar los cambios en la rama.
5. Una vez revisados, pueden usar git checkout y combinar la rama con la principal.
Por último, cualquier persona con acceso de mantenedor puede crear una solicitud
de cambios en el upstream original para iniciar los cambios en el repositorio original
(pull).

Crear un proyecto derivado de otro proyecto


1. Como punto de partida, puedes optar por bifurcar (fork) un proyecto. El repositorio
desde el que realizas la bifurcación se denomina repositorio anterior.
2. Para contribuir con tus cambios al proyecto inicial, al que no tienes acceso, puedes
enviar un Pull Request (PR).
3. Los responsables del proyecto inicial pueden revisar los cambios introducidos en la
solicitud de cambios, enviar sus comentarios y realizar la fusión (merge)
correspondiente.
4. Puedes crear una copia idéntica del repositorio remoto mediante git clone. El
repositorio remoto desde el que se clona el proyecto también se denomina origen.
Para crear ramas y sincronizar los cambios, los comandos de git que se utilizan son:
● git branch: Para crear una rama.
● git checkout: Para activarla.
● git add y git commit: Para guardar los cambios.
● git merge: Para combinar los cambios en la rama principal.
● git push: Para añadir los cambios al repositorio de GitHub.
Resumen: Flujos de trabajo Git con comandos Git
● GitHub has over 100 million repositories. You can clone a repository and sync
changes back to the original. You can also fork a repository and use it as the base for
the new project or work on that project independently.
● The steps included in a GitHub workflow are:
○ Clone the remote repository or initialize a Git repository.
○ Move files to a staging area.
○ Perform an initial commit.
○ Create a branch and work on it.
○ Add files to the staging area and commit.
○ Push local commits to the remote repository.
○ Create a pull request for review and merging.
○ Use the pull operation to update the local repository.
● Multiple roles are involved in managing a project: Developer, Integrator, and
Repository Administrator.
○ A Developer working in a group project uses commands like git clone, git pull,
git fetch, git push, and git request-pull in addition to the ones needed by a
standalone developer.
○ An Integrator in a group project reviews and integrates changes made by
others. Integrators use commands like git pull, git revert, and git push in
addition to the ones needed by participants.
○ Repository Administrators structure how the repository is organized and how
users interact with the repository. They also configure the servers needed for
accessing the web services and documentation, define email and index
settings, and manage the look and feel of the application.

Glosario: Comandos Git y gestión de proyectos GitHub

Term Definition

A process of creating a copy of the project's code and its complete


Cloning
version history from the remote repository on the local machine.

A snapshot of the project's current state at a specific point in time, along


Commit
with a description of the changes made.

Developer A computer programmer who is responsible for writing code.


A system that keeps track of changes to code, regardless of where it is
Distributed stored. Multiple users work on the same codebase or repository, mirroring
version control the codebase on their computers if needed, while the distributed version
system (DVCS) control software helps manage synchronization amongst the various
codebase mirrors.

Fork A copy of a repository into your GitHub account.

Forking creates a copy of a repository on which one can work without


Forking
affecting the original repository.

GitHub A web-hosted service for the Git repository.

A free and open-source software distributed under the GNU General


Public License. It is a distributed version control system that allows users
Git
to have a copy of their own project on their computer anywhere in the
world.

Integrator A role that is responsible for managing changes made by developers.

A branch that stores the deployable version of your code. The master
Master branch
branch is created by default and is definitive.

A process to combine changes from one branch to another, typically


Merge
merging a feature branch into the main branch.

Origin A term that refers to the repository where a copy is cloned from.

A process used to request that someone review and approve your


Pull request
changes before they become final.
Remote Repositories that are stored elsewhere. They can exist on the internet, on
repositories your network, or on your local computer.

Repository A role that is responsible for configuring and maintaining access to the
administrator repository.

A data structure for storing documents, including application source code.


Repository
It contains the project folders that are set up for version control.

An area where commits can be formatted and reviewed before


Staging area
completing the commit.

A term used by developers to refer to the original source where the local
Upstream
copy was cloned from.

A system that allows you to keep track of changes to your documents.


Version control This process allows you to recover older versions of the documents if any
mistakes are made.
Github
1. Code: aquí es donde residen todos los archivos fuente. Git se creó inicialmente
como un repositorio de código fuente y ahora todo tipo de archivos acaban aquí. Si
has creado un README y/o una licencia, eso es todo lo que tienes aquí ahora
mismo.
2. Issues: como puedes imaginar, puedes hacer un seguimiento y planificar con
herramientas como «Problemas», que enumera todos los elementos pendientes en
función de tu base de proyectos.
3. Pull requests: esto forma parte del mecanismo de colaboración con otros usuarios.
Las solicitudes de extracción definen los cambios que están confirmados y listos
para ser revisados antes de incorporarlos a la rama principal.
4. Projects: todas las herramientas para gestionar, clasificar, planificar, etc., sus
diversos proyectos. Este es el núcleo del poder colaborativo de GitHub.
5. Wiki, Security e Insights: estas herramientas, que suelen reservarse a usuarios
más avanzados, proporcionan una base de comunicación con la comunidad de
usuarios externos.
6. Settings: GitHub permite una gran cantidad de personalizaciones, como cambiar el
nombre del repositorio y controlar el acceso.

Pasos de un flujo de trabajo de git


1. Cuando te unes a un proyecto existente, primero clona el repositorio remoto.
2. A continuación, crea una rama desde el repositorio principal y trabaja en ella.
3. Añade archivos actualizados al área de ensayo y comprométete con la rama.
4. Envía las confirmaciones al repositorio remoto.
5. Crea una solicitud de cambios para fusionar la rama con la rama principal, que el
responsable del mantenimiento revisará y aprobará.
6. Cuando comiences un proyecto nuevo, inicializa un repositorio git local.
7. A continuación, selecciona los archivos de los que quieres que Git realice un
seguimiento, muévelos a un área de ensayo y realiza una confirmación inicial.
8. Crea un repositorio remoto en blanco y establece un enlace con tu repositorio local.
9. Introduce los cambios para que otros desarrolladores puedan clonar este repositorio
remoto y seguir el flujo de trabajo habitual para actualizar los archivos del proyecto.

You might also like