開発から何年も遠ざかっていたので、まるっきり初心者としてGitの使い方を纏めておく。
1.Gitのインストール
公式サイトからGit for Windowsをダウンロード(Git-2.16.1-64-bit.exe)。
https://git-for-windows.github.io/
・Choosing the default editor used by Gitでは『Use VisualStudioCode as Git's default editor』を選択。
・Configuring the line ending conversionsでは、
改行コードは変換されたくないので、『Checkout as-is, commit as-is』を選択。
2.Gitの設定
Windowsメニューから『Git Bash』を立ち上げユーザ情報を設定。
git config --global user.name "名前"
git config --global user.email メールアドレス
git config --global core.quotepath false
3.作業フォルダの設定
"C:\Users\xxx\Documents\git_home\alexa_samples"を作成し、Git Bashで移動。
「git init」コマンドでGitリポジトリを初期化。
「git status」コマンドでステータスを確認。
1.Gitのインストール
公式サイトからGit for Windowsをダウンロード(Git-2.16.1-64-bit.exe)。
https://git-for-windows.github.io/
・Choosing the default editor used by Gitでは『Use VisualStudioCode as Git's default editor』を選択。
・Configuring the line ending conversionsでは、
改行コードは変換されたくないので、『Checkout as-is, commit as-is』を選択。
2.Gitの設定
Windowsメニューから『Git Bash』を立ち上げユーザ情報を設定。
git config --global user.name "名前"
git config --global user.email メールアドレス
git config --global core.quotepath false
"C:\Users\xxx\Documents\git_home\alexa_samples"を作成し、Git Bashで移動。
「git init」コマンドでGitリポジトリを初期化。
「git status」コマンドでステータスを確認。
事前に作成しておいたHoroscopeSkill.jsが管理できていないとのメッセージ。
4.「git add」でファイルをGitに追加
「git add HoroscopeSkill.js」でファイルを追加。
「git status」でファイルが追加されたことを確認。
5.「git commit」で「リポジトリ」にコミット
「git commit」コマンドで「リポジトリ」にコミットします。
「git commit -m "commentを書きましょう"」を入力。
6.Visual Studio Code(VS Code)でGitを使う
VS Codeの「フォルダーを開く」で作業フォルダ
"C:\Users\xxx\Documents\git_home\alexa_samples"を開く。
ソース管理タブを表示すると「有効なソース管理プロバイダーがありません」が消えて、右上に「…」があり、そこからGitコマンドが使用できます。
4.「git add」でファイルをGitに追加
「git add HoroscopeSkill.js」でファイルを追加。
「git status」でファイルが追加されたことを確認。
「git commit」コマンドで「リポジトリ」にコミットします。
「git commit -m "commentを書きましょう"」を入力。
最後にgit statusでcleanになったことが確認できます。
6.Visual Studio Code(VS Code)でGitを使う
VS Codeの「フォルダーを開く」で作業フォルダ
"C:\Users\xxx\Documents\git_home\alexa_samples"を開く。
ソース管理タブを表示すると「有効なソース管理プロバイダーがありません」が消えて、右上に「…」があり、そこからGitコマンドが使用できます。
7.コマンドまとめ
git init →作業ディレクトリの追加
git status →ステータス確認
git add ファイル名 →ファイルの追加
git commit -m "コメント" →ファイルのコミット
git log →履歴の確認
git log -p →履歴の詳細表示
コメント
コメントを投稿