LoginSignup
0
0

More than 3 years have passed since last update.

Gitコマンドの備忘録

Last updated at Posted at 2019-04-20

Gitコマンドの備忘録

概要

  • gitコマンドをよく忘れるので。。。整理しました。

参考資料

コマンドたち

GitHubにリポジトリ作成

gitリポジトリの初期化

$ cd [gitリポジトリにしたいディレクトリ]
$ git init
  • .gitディレクトリが作成されればOK

ステージ領域にファイルを追加

$ git add [対象ファイル] 

リポジトリの状態確認

$ git status
  • gitリポジトリの状態を確認できる。
  • gitリポジトリに登録されていないファイルは「Untracked files:」に表示される。
  • gitリポジトリに登録さらたファイルは「Changes to be committed:」に表示される。

リポジトリの履歴を記録

$ git commit -m "コメント"
[master (root-commit) 325b742] first commit
 1 file changed, 152 insertions(+)
 create mode 100755 .zshrc

リモートリポジトリを登録

$ git remote add origin git@github.com:[ユーザ名]/[リポジトリ].git

リモートリポジトリへ送信

$ git push -u origin master
Enter passphrase for key '/Users/XXXXXXXX/.ssh/id_rsa_github':
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 2.25 KiB | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:[ユーザ名]/[リポジトリ].git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

全てのブランチの確認

$ git branch -a

現在のブランチの確認

$ git branch

ブランチの作成

$ git branch [ブランチ名]

ブランチを変更する

$ git checkout [ブランチ名]
0
0
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
0