¡Tutorial básico de Git y preguntas comunes! ¡Debes entenderlo de un vistazo!

¡Tutorial básico de Git y preguntas comunes! ¡Debes entenderlo de un vistazo!

Plomo: GitRoad - Git command
Autor: conviértete en excelentes
pasatiempos blancos : ¡Americano un poco de hielo!

Nota: Si encuentra algo que no comprende a la mitad, puede comentar directamente y dejar un mensaje, ¡y responderá preguntas de inmediato! ¡No decir nada!

Tabla de contenido

enlaces relacionados

Git varias áreas

  • Área de trabajo ( workspace)
  • Área de almacenamiento temporal ( index)
  • Almacén local ( local repository)
  • Almacén remoto ( remote repository)

Uso básico

# 初始化git
$ git init
# 克隆项目到本地
$ git clone xx(https/ssh)
# 提交文件到缓存区
$ git add .
# 提交到本地仓库
$ git commit -m ‘提交信息’
# 推送到远程的分支master
$ git push -u origin branch

problema comun

Cuando .gitignore falla

# 清除缓存区里面的所有文件,包括了.gitignore
$ git rm -r --cached .

-> Entonces, uso básico

Necesita cambiar de usuario

# 查看全局配置
$ git config —list 
# 配置全局变量,切换用户
$ git config —global user.name “xx”
$ git config —global user.email “xx”

Si no hay rama ascendente

$ git push --set-upstream origin xx(branch)

Ver todas las ramas

$ git branch

Eliminar rama remota

$ git push origin —delete xx(branch)

Eliminar sucursal local

$ git branch -d xx(branch)

Asociar repositorio de github

$ git remote add origin xx(git url)

Si existe la rama remota

$ git remote rm origin

Actualice el contenido más reciente del maestro en la sucursal.

$ git pull --rebase origin master

Sube archivos locales a git

$ git add .
$ git commit -m ‘’
$ git remote add  origin xx(git地址)
$ git push -u origin master
# 若遇到地址本身有文件,发送冲突
$ git pull —rebase origin master

Si no se rastrea algún archivo

# 查看未跟踪文件
$ git status
# 添加跟踪
$ git add xx(文件/文件夹)

Rama adelante

Problema: Your branch is up to date with 'origin/feat/crh
Resolver:

# checkout if exist error
$ git status
# create new branch
$ git checkout -b feat/xx
# add&commit&push
# change branch&merge
$ git checkout master
$ git merge feat/xx
Conclusión: Si tiene alguna pregunta o sugerencia, ¡puede dejar un comentario directamente! ¡Te responderé uno por uno! !
Si el blog de Xiaobai tiene sugerencias o críticas, ¡simplemente deje un comentario a continuación! Si crees que Xiaobai es bastante bueno, ¡deja tus gustos y atención! !

Supongo que te gusta

Origin blog.csdn.net/weixin_44425934/article/details/108593086
Recomendado
Clasificación