LoginSignup
0
1

More than 3 years have passed since last update.

git操作のまとめノート

Posted at

1.gitの基本設定

1.1 アカウントの設定

$ git config --global user.name "Your Name"
$ git config --global user.email your@example.com

1.2 ブランチをpushするときの設定:

ブランチは指定されていない場合、現在のブランチへpushしたい時に、

$ git config --global push.default simple

2.gitの初期化

2.1 gitの初期化

$ cd ~/Code/Laravel
$ git init

2.2 ファイルの内容を全てステージングする

$ git add -A

2.3 Gitの状態を確認

$ git status

2.4 変更をコミット、コメントする

$ git commit -m "コメント"

2.5 コミットの歴史を探る

$ git log

2.6 ソースをGitHubへ

$ cd ~/Code/Laravel
$ git remote add origin git@github.com:your_username/hello_laravel.git
$ git push -u origin master

3 ブランチの操作(ローカル編)

3.1 ローカルで新しいブランチを作る

$ git checkout master
$ git checkout -b static-pages

3.2 別のブランチをmasterブランチにマージ

$ git checkout master
$ git merge static-pages

3.3 コードをGitHubへpush

$ git push

3.4 ローカルのブランチを削除する

$ git branch -d static-pages

4 ブランチの操作(リモート編)

4.1 Githubのリモートアドレスを確認

$ git remote -v

4.2 全てのリモートブランチを確認

git branch -a

4.3 ログを確認する

$ git log origin/master -n 3

4.4 ローカルブランチとリモートブランチとの対応関係を確認する

$ git branch -vv

4.5 リモートブランチを作る

//ローカルブランチを作る
$ git checkout -b new-branches

//リモートへpush
$ git push origin new-branches

4.6 リモートブランチをローカルへpullし、名付ける

$ git pull
$ git checkout -b ローカルブランチ名x origin/リモートブランチ名x

4.7 リモートブランチを削除する

$ git branch -r -d origin/new-branches
$ git push origin :new-branches
0
1
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
0
1