Gitコマンドライン
Feb 19 2023
git コマンドのすべて バージョン管理システムのヘルプ 開発者が協力して作業し、すべてのバージョンの履歴を同時に管理する VCS の種類 : CVCS : 集中バージョン管理システム DVCS : 分散バージョン管理システム Git ライフ サイクル Git のインストール Ubuntu sudo apt-get install git Windows以下からダウンロード リンク git --version git stash 参照を初期化します。
git コマンドについて
バージョン管理システム
開発者が協力して作業し、すべてのバージョンの履歴を同時に管理するのに役立ちます
VCS の種類 :
CVCS : 集中バージョン管理システム
DVCS : 分散バージョン管理システム
Git のライフサイクル
Gitのインストール
Ubuntu
- git パッケージは apt 経由で利用可能です
- apt-getを使用してgitをインストールする
sudo apt-get install git
ウィンドウズ
以下のリンクからダウンロードしてください
- インストーラーが正常に起動すると、画面にgit セットアップが表示されるはずです。次へおよび終了プロンプトに従って、インストールを完了します。
git --version
初期化する
- Git Initialize コマンドは、新しいバージョン管理されたプロジェクトの作成または初期化に使用されます。Git には、既存のサーバー権限や管理者権限は必要ありません。
- 以下に示す初期化用のコマンドがいくつかあります。
git init:現在のディレクトリを Git リポジトリに変換しますgit clone: git clone は、既存のリポジトリのコピーを作成するために使用されます。内部的には、git clone は最初に git init を呼び出して新しいリポジトリを作成します。git add:ファイルはステージング領域に移動します
> `git add .` : all Files goes to staging area
> `git add file1.txt file2.txt` : specific Files goes to staging area
> `git add *.txt` : only extenction files staging area
> `git restore --staged FILE_NAME` : restore file from staging area
git push:ファイルをローカル リポジトリからリモート リポジトリにプッシュしますgit fetch:リモート リポジトリからローカル リポジトリにファイルをインポートするために使用されますgit pull : 2つのコマンドを組み合わせたものでfetch 、merge> git init
> git add README.md
> git commit -m "commit"
> git branch -M main
> git remote add origin REPO_URL
> git push -u origin main
- グローバル Git 構成ファイルは、
.gitconfigユーザーのホーム ディレクトリにある名前のファイルに保存されます。オペレーティング システムに応じて次のようになります。 - 特定の値を保存するための特定のコマンドがいくつかあります
> git config --global user.name ""
> git config --global user.email ""
> git config --global user.password ""
> git config --global core.editor "code --wait"
> git config --global -e
> git config --global credential.helper store : store the credentials
> git config --global --unset credential.helper : unset the credentials which are set
> git remote set-url origin https://[email protected]/USER_NAME/REPO_NAME.git
> git config --local user.name "UserName"
> git config --local user.email "email Address"
> git config --local user.password "personal Token"
> git config credential.helper store : store the credentials
> git config --local --unset credential.helper: unset the credentials which are set
> git commit -m "message"
> git commit --amend : Add Description or change commit message of the last previous commit
> git commit -am "message" : commit without stageing
> git reset --hard COMMIT_ID : delete old commit
> git reset --hard HEAD~COMMIT_NUMBER : delete old commit using HEAD pointer
> git reset --soft COMMIT_ID : delete old commit using HEAD pointer
> git show COMMIT_ID : show Actual Commit
> git revert Commit_ID : It will revert you code till Commit_ID
git スタッシュ
- コミットされていない変更を取得し、後で使用できるように保存し、作業コピーから元に戻します。
git stash:リポジトリの変更をローカルに隠しますgit stash pop:現在隠している変更を隠します。
- git ブランチはメイン リポジトリの新しいバージョンです。
- 大規模なプロジェクトに取り組んでおり、クライアントがライブプロジェクトに影響を与えずに機能を更新したい場合、分岐は便利です。
- 作業が完了したら、メイン リポジトリに新しいブランチを作成する必要があります。作業が完了したら、フィーチャー ブランチをメインにマージして、更新がメイン ブランチにマージされるようにします。
> git branch Branch_Name : create new branch
> git checkout Branch_Name : change the branch
> git branch Old_Branch_Name New_Branch_Name : Rename branch
> git branch -D Branch_Name : Delete branch
> git log main..child : shows the unmarged commits
git merge Branch_Name:子ブランチを親とマージします
git merge --squash Branch_Name:スカッシュでマージ (サブブランチのコミット履歴を削除し、単一のコミットでマージ)
- git rebase コマンドを使用すると、一連のコミットを簡単に変更し、リポジトリの履歴を変更できます。コミットを並べ替え、編集、またはまとめて潰すことができます。
git rebase Branch_Name: Rebaseを使用したマージ(最初のブランチのベースのみ変更)
- git Cherry-pick は、任意の Git コミットを参照によって選択し、現在作業中の HEAD に追加できるようにする強力なコマンドです。
git cherry-pick COMMIT_ID_1 COMMIT_ID_2:特定のコミットを使用したマージ

![とにかく、リンクリストとは何ですか?[パート1]](https://post.nghiatu.com/assets/images/m/max/724/1*Xokk6XOjWyIGCBujkJsCzQ.jpeg)



































