registro de método de aplicación de rutina de software git

(1). Almacén local

  1. Crea un directorio no chino administrado por git

  2. Ejecute el comando git init en este directorio

  3. Ejecute el comando en el directorio del repositorio local:

git config --global user.name "tu nombre de usuario"

git config --global user.email "su buzón"

  1. 安装 ssh-keygen
    sudo apt-get install openssh-client ssh-keygen

  2. Genere la clave ssh, cópiela en la mesa de trabajo y ejecute el comando:
    ssh-keygen -t rsa -C "su buzón"
    #Pegue el
    clip de comando <~ / .ssh / id_rsa.pub

  3. Registre una cuenta, https://github.com/ o gitlab empresarial

  4. Configuración -> Configuración-SSH, cree una nueva clave SSH y pegue id_rsa.pub en las claves

  5. La prueba es exitosa, ejecute el comando:
    ssh -T [email protected]

(2) Almacén remoto asociado

  1. Almacén local asociado con el almacén remoto
    Vaya a github y busque la dirección SSH del almacén que comienza con [email protected]: en el almacén Clone o descargue la lista desplegable y cópiela (porque HTTPS es lento, generalmente use la dirección SSH)
    git remote add origen la dirección que copió
    git remoto agregar origen xxxxx

  2. Sincronizar almacén remoto

Nota: Si hay archivos en el almacén remoto, primero extraiga el contenido del almacén remoto
git pull origin master
y luego combine el código local, envíe el código al almacén remoto
git push -u origin master
Nota: Cuando el almacén remoto es vacío, puede forzar la sincronización del almacén remoto
git push -u -f origin master

3. Vuelva a asociar el almacén remoto:
git remote rm orgin // Elimine la dirección original del almacén
remoto git remote add group // La dirección del almacén remoto recién asociada
git pull group master
git push -u group master

  1. El método de asociación de
    submódulos git submodule init # Inicializar el archivo local .gitmodules
    git submodule agregar <submodule_url> # Agregar la URL del subproyecto
    git submodule update # Sincronizar el código fuente del submódulo remoto

Métodos para cargar submódulos locales, por ejemplo:

robot@ubuntu:~/routeMonitor/monitor_src/third_party/serial$ git reflog
cbcca7c HEAD@{
    
    0}: clone: from https://github.com/wjwwood/serial.git
robot@ubuntu:~/routeMonitor/monitor_src/third_party/serial$ cd ../../
robot@ubuntu:~/routeMonitor/monitor_src$ git submodule add https://github.com/wjwwood/serial.git
Cloning into 'serial'...
remote: Enumerating objects: 2659, done.
remote: Total 2659 (delta 0), reused 0 (delta 0), pack-reused 2659
Receiving objects: 100% (2659/2659), 1.55 MiB | 354.00 KiB/s, done.
Resolving deltas: 100% (1240/1240), done.
Checking connectivity... done.

robot@ubuntu:~/routeMonitor/monitor_src$ git status
On branch master
Your branch is up-to-date with 'DevGroup/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
	new file:   .gitmodules
	new file:   serial
  1. Eliminar la carpeta de prueba como un caso
    git rm -r --cached test // - cached no eliminará la prueba local
    git commit -m'delete test dir '
    git push -u origin master

  2. Agregar archivo
    git add…
    por ejemplo: git add ConfigVersionNumber.h

  3. Confirme el contenido combinado
    git commit -am "he c_with_ui.cpp file macro definition"
    push to the server, submit the application
    git push origin master

  4. Envíe la
    interfaz web de la aplicación de fusión e inicie sesión en la cuenta de github, puede enviar la aplicación de código actual para fusionarse en el grupo de I + D.

(3). Resolver conflictos de fusión

Herramientas básicas:
sudo apt install kdiff3

  1. Ver versión fusionar contenido de conflicto
    git mergetool

  2. Resolver conflictos de fusión
    git difftool

  3. Confirme la fusión
    git commit -am "Fusionar completado"

  4. Enviar código local
    git push origin master

(4). Crear rama y fusionar rama

  1. Crear rama
    git branch dev

  2. Una vez que el código de la rama dev alcanza el estándar en línea, debe fusionarse con la rama maestra
    git checkout dev
    git pull
    git checkout master
    git merge dev
    git push -u origin master

  3. Cuando el código maestro cambia, necesita actualizar el código en la rama de desarrollo (dev)
    git checkout master
    git pull
    git checkout dev
    git merge master
    git push -u origin dev

(5). Revertir una versión específica

1). 在git工作路径,git reflog 查看本地,git log查看远程。
2). 查看指定历史版本 tree 的 SHA; 
3). 指定远程 commit 值
			$ git checkout 4dc7ce33fab01e8ff1858968062c6d57bf2e7571
			
			/*
			Note: checking out '4dc7ce33fab01e8ff1858968062c6d57bf2e7571'.
			You are in 'detached HEAD' state. You can look around, make experimental
			changes and commit them, and you can discard any commits you make in this
			state without impacting any branches by performing another checkout.			
			
			If you want to create a new branch to retain commits you create, you may
			do so (now or later) by using -b with the checkout command again. Example:
			git checkout -b <new-branch-name>
			*/	
			
			$ git branch
			* (HEAD detached at 4dc7ce3)
			  brain_8.10
			  dev
			  master
4). 把此分支check到 此分支上
		git checkout -b brain_8_9 

5). //把此分支推到服务器上,服务器上就出现版本的分支代码 
		git push origin brain_8_9 

6).切换至另一文件夹内,下载分支代码。
$ git clone -b brain_8_9 ssh://git@git.keyi.lan:10022/lijiabo/cellrobot2_app.git
				Cloning into 'cellrobot2_brain_app'...
				remote: Enumerating objects: 1913, done.
				remote: Counting objects: 100% (1913/1913), done.
				remote: Compressing objects: 100% (1456/1456), done.
				remote: Total 1913 (delta 1460), reused 578 (delta 451)
				Receiving objects: 100% (1913/1913), 556.19 KiB | 7.32 MiB/s, done.
				Resolving deltas: 100% (1460/1460), done.
$ ls
	cellrobot2_app
$ git branch
   * dev
	master

Documento de instrucciones de Git
https://git-scm.com/book/zh/v2

Supongo que te gusta

Origin blog.csdn.net/weixin_38387929/article/details/112789914
Recomendado
Clasificación