LoginSignup
1
0

More than 3 years have passed since last update.

Gitリポジトリ追加からの流れ

Last updated at Posted at 2019-07-17

忘れるといけないのでリポジトリ追加から流れだけささっと。

①トップの New repository から進んで Create a new repository 画面へ

Repository name 入力後、Initialize this repository with a README にチェック

/users/<name>/gitがなければGitのリポジトリを作る(または初期化する)ためにinitする必要がある。

terminal
/users/sf213471118/git
$ git init

/users/<name>/git/.gitが作られたことを確認する

terminal
/users/sf213471118/git
$ ls -a
.       .DS_Store   .git

git直下に/.gitというサブディレクトリが作られたらCommitに向けてCloneする。


④リポジトリを選択し Clone or download を押下したらアドレスをコピーする(SSHを使用)

アドレスの構成は以下の通り

[user] @ [host] : [Repository adress]

ターミナルで早速Clone

terminal
/Users/sf213471118/git
$ git clone <user>@<host>:xxx/test.git
Cloning into 'test'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
$ cd test/
$ ls
README.md        /* リポジトリに格納してあるファイルが確認できた */

⑤試しにREADME.mdを書き換える。

README.md
# test

abcdef
~
~

Commit Logに変更箇所を明示的に記録しておくためにaddする。

addのオプションは複数あるが、変更を全て適用する場合は -A or --all を使用(どちらでもOK)

terminal
/Users/sf213471118/git/test
$ git add -A
$ git add --all

⑦gitリポジトリにファイルの変更を保存するためcommitする。

このとき-mを用いることで変更時のコメントを追加することができる。

terminal
/Users/sf213471118/git/test
$ git commit -m "first commit"
[master 0226a81] first commit
 Committer: sf213471118 <xxx@xxx.xxx>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

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

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 7 insertions(+), 1 deletion(-)

⑧ローカルリポジトリで変更した箇所をリモートリポジトリにpushする。

terminal
/Users/sf213471118/git/test
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 266 bytes | 266.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: detect-secrets-stream (beta) ver=xxx-212s7c2b78321f0836d59e162s57975656hejskw FAQ: xxxx
remote: 
remote: Successfully send push metadata.
remote: Push info collect pre-receive hook finished within 3 seconds.
To <user>@xxxxx/test.git
   w412d92..9274q73  master -> master

この変更がリモート上で反映されているかをGitHubで確認する。

1
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
1
0