-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-basic.txt
More file actions
executable file
·118 lines (85 loc) · 3.41 KB
/
Copy pathgit-basic.txt
File metadata and controls
executable file
·118 lines (85 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#################################################################################
# Comandos basicos de git
#################################################################################
# identificar usuario del repositorio de git
git config --global user.email "calderongz@gmail.com"
git config --global user.name "Marco Iñiguez"
# iniciar un repositorio de git
git init
# consultar el estado del repositorio de git
git status
# añadir archivos al el repositorio de git
git add archivo.txt
# añadir todos los archivos del repositorio
git add .
# confirmar cambios en el repositorio de git (commit)
git commit -m "Comandos basico de git"
# consultar commits
git log
commit f0d2018f28c62c43529b6a97e4d91a706c95a60f (HEAD -> master)
Author: Marco Iñiguez <calderongz@gmail.com>
Date: Thu Mar 3 15:31:08 2022 -0500
Añadido titulo al archivo
commit be48cde7b52bec0c1e0f94e20386ed9a16aab742
Author: Marco Iñiguez <calderongz@gmail.com>
Date: Thu Mar 3 15:25:49 2022 -0500
Comandos basicos de git
# consultar commits en una sola linea
git log --oneline --graph
# para cambiar de una version de un archivo a otra
git checkout be48c
# volver a la ultima version
git checkout master
# deshacer cambios de un archivo para limpiar
git reset be48 # Deshace commits sin modificar archivos
git reset --hard be48 # Deshace commmits y modifica los archivos
# restaurar un archivo si se borra
git restore archivo.txt
#################################################################################
# Comandos de git para subir repositorios locales a github
# https://github.com/
#################################################################################
# Se debe crear un cuenta en github y su repositorio correspondiente.
# Se crea clave SSH para poder autenticarse a github
# https://github.com/settings/keys
ssh-keygen -t ed25519 -C "calderongz@gmail.com"
# Se sube clave publica que se creo a github
cat .ssh/id_ed25519.pub
# se adiciona servidor remoto del repositorio (SSH)
git remote add origin git@github.com:calderongz/git.git
# se consulta repositorio remoto SSH
git remote -v
# subir repositorio local a github
git push --set-upstream origin master
git push -u origin master
# clona repositorio, si pierdes los archivos.
git clone git@github.com:calderongz/mastermind-git.git
# adiciona llave publica de usuario a ssh-agente para que no solicite contraseña,
# aplica solamente durante sesion activa.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Como crear y cambiar de ramas local
git checkout -b feature-post-styles
# listar ramas disponibles
git branch
# crear ramas remotas en github
git push -u origin feature-post-styles
# mezclar ramas locales
git merge feature-load-adds-from-api
# descargar rama
git pull origin bugfix-62-only-two-comments
###########################################################################
# Comandos para resolver conflictos
###########################################################################
# 1. Clona o actualiza tu repositorio local con los ultimos cambios
# git clone git@github.com:calderongz/mastermind-git.git git-bug1
git checkout master
git pull
# 2. Mezcla la rama base en la rama principal.
git merge bugfix-6-only-three-comments
# 3. Resuelve los conflictos y haz un commit de los resultados
git add .
git commit -m "Merge pull request #6 bugfix-6-only-three-comments"
# 5. Sube los cambios.
git push
###########################################################################