gitソフトウェアルーチンアプリケーションメソッドレコード

(1)地元の倉庫

  1. gitが管理する中国語以外のディレクトリを作成する

  2. このディレクトリでコマンドgitinitを実行します

  3. ローカルリポジトリディレクトリでコマンドを実行します。

git config --global user.name "your username"

git config --global user.email "あなたのメールボックス"

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

  2. sshキーを生成し、それをペーストボードにコピーして、次のコマンドを実行します。ssh
    -keygen-t rsa -C "your
    namespace " #Paste command
    clip <〜/ .ssh / id_rsa.pub

  3. アカウントを登録します、https://github.com/またはエンタープライズgitlab

  4. 設定->設定-SSH、新しいSSHキーを作成し、id_rsa.pubをキーに貼り付けます

  5. テストは成功しました。次のコマンドを実行し
    ますssh -T [email protected]

(2)リモートウェアハウスを関連付ける

  1. リモートウェアハウスに関連付けられているローカルウェアハウス
    githubに移動し、git @ github.comで始まるウェアハウスSSHアドレスを見つけます。ウェアハウスの[クローン]またはダウンロードドロップダウンリストでコピーします(HTTPSは遅いため、通常はSSHアドレスを使用します)
    git remote add originコピーしたアドレス
    gitremote add origin xxxxx

  2. リモートウェアハウスを同期する

注:リモートウェアハウスにファイルがある場合は、最初にリモートウェアハウスのコンテンツをプルします
。gitpullorigin master
次にローカルコードをマージし、コードをリモートウェアハウスに
プッシュします。gitpush-u origin master
注:リモートウェアハウスが空の場合、リモートウェアハウスの同期を強制できます
git push -u -f origin master

3.リモートウェアハウスを再関連付けします
。gitremotermorgin //元のリモートウェアハウスアドレスを削除しますgitremote
add group //新しく関連付けられたリモートウェアハウスアドレスgitpull
group master
git push -u group master


  1. サブモジュールの関連付けの方法gitsubmodule init#ローカルの.gitmodulesファイルを初期化します
    git submodule add <submodule_url>#サブプロジェクトのURLを追加します
    git submodule update#リモートサブモジュールのソースコードを同期します

ローカルサブモジュールをアップロードする方法例:

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. ケースとしてテストフォルダを削除しますgitrm
    -r --cached test //-
    cachedは、ローカルテストを削除しませんgit commit -m'delete test dir '
    git push -u origin master

  2. ファイルを追加しますgitadd

    eg:git add ConfigVersionNumber.h

  3. マージされたコンテンツの
    gitcommit -am "he c_with_ui.cpp file macro Definition"
    プッシュをサーバーに確認し、アプリケーション
    git push originmasterを送信します

  4. マージアプリケーションの
    Webインターフェイスを送信してgithubアカウントにログインすると、現在のコードアプリケーションを送信してR&Dグループにマージできます。

(3)マージの競合を解決します

基本ツール:
sudo apt install kdiff3

  1. バージョンマージの競合コンテンツを表示する
    gitmergetool

  2. マージの競合を解決する
    gitdifftool


  3. マージgitcommit-am「マージが完了しました」を確認します

  4. ローカルコードを送信する
    gitpush origin master

(4)ブランチを作成し、ブランチをマージします

  1. ブランチ
    gitブランチ開発を作成します

  2. devブランチのコードがオンライン標準に達した後、マスターブランチにマージする必要があります
    git checkout dev
    git pull
    git checkout master
    git merge dev
    git push -u origin master

  3. マスターコードの変更は、あなたが開発ブランチ上のコード(DEV)を更新する必要がある
    gitのチェックアウトのマスター
    gitのプルを
    gitのチェックアウトDEV
    gitのマージマスター
    Gitのプッシュ-u原点DEV

(5)特定のバージョンをロールバックする

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

Gitの説明ドキュメント
https://git-scm.com/book/zh/v2

おすすめ

転載: blog.csdn.net/weixin_38387929/article/details/112789914