忘れるといけないのでリポジトリ追加から流れだけささっと。
①トップの 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で確認する。