GitHubで初めてのコミット
まず始めにリポジトリを作ります。
GitHubの画面の右下にある「New repository」をクリック
リポジトリの名前を入れます
次いでローカルリポジトリを作ります・・が
その前に初期設定をします
$ git config --global user.name '<user_name>' $ git config --global user.email '<user_email>' $ git config --global alias.co checkout $ git config --global alias.st status $ git config --global alias.ci commit
ローカルリポジトリ作ります。
まずは適当な箇所にディレクトリを作って移動します
$ mkdir /var/www/tutorial $ mv /var/www/tutorial
移動したらディレクトリを初期化します
これで.gitが作成され、管理下におかれました。
$ git init Initialized empty Git repository in .git/
なんでもいいのでファイルを作ります
$ vim sample.txt $ git st # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # sample.txt
インデックスに登録します
$ git add sample.txt $ git st # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: sample.txt #
コミットします
$ git commit -m "first commit" [master (root-commit) 6069b73] first commit 1 file changed, 1 insertion(+) create mode 100644 sample.txt
ここからリモートリポジトリにようやくコミットをしていきます
まずは名前を付けます。今後はoriginという名前にします
$ git remote add origin <リポジトリのURL>
pushします。ユーザー名とパスワードを求められるので登録したものを入れてください。
$ git push origin master
これでGitHub上にコミット完了です。