LoginSignup
2
2

More than 5 years have passed since last update.

git ブランチ作成関係と設定ファイルのメモ

Posted at

ローカルのブランチからブランチを作成する方法

ブランチを作りたいgitのディレクトリに入る

cd ディレクトリパス

ブランチの一覧を見る

git branch -a

ブランチを作る元のブランチに切り替える

git checkout master

ブランチを作成

git checkout -b develop
git checkout -b 作成するブランチ名

ブランチの一覧を見る

git branch -a

実行結果
* develop
  master
  remotes/origin/master

ブランチをリモートに登録

git push -u origin 作成したブランチ名

リモートブランチから作る方法

リモートブランチからローカルブランチを作成

git checkout -b ローカルに作成するブランチ名 origin/作成元のリモートのブランチ名

ブランチの一覧を見る

git branch -a

gitでpushできない時に試したこと(githubでpushできない時などは、branchが違う可能性があるのでブランチを切り替えてpushするか作成したbranchでpushしてあげる。)

git push -u origin develop

ブランチをリモートに登録

git push -u origin 作成したブランチ名

Gitの設定ファイルの種類と場所(system,global,local)

種類 対象範囲 場所 備考
system システム全体(全ユーザーの全リポジトリ) /etc/gitconfig
global 該当ユーザーの全リポジトリ ~/.gitconfig ホーム直下
local 該当リポジトリ repository/.git/config リポジトリの.git直下

設定項目の確認

git config <name>

nameに値する例
- color.ui : Gitの出力の色分け(通常はautoと設定)
- core.editor : コミットメッセージなどの編集で用いるエディタ
- user.name : ユーザー名
- user.email : Eメール

設定の一覧表示
git config --local
git config --global
git config --system

設定を上書きする方法

git config --global user.email example@example.com(value値)

設定ファイルをエディタで直接編集(複数修正がある時など)

git config -e #ローカルの設定を変更
git config --global -e
git config --system -e
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2