Windows10でGitを使う備忘録2
GitHubからclone
リポジトリからチェックアウト用のURLをコピー。
Windows上で、チェックアウトするディレクトリ内でGit Bashを開き、cloneコマンドを入力。
$ git clone https://github.com/shiragishi/hello-git.git Cloning into 'hello-git'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done.
ディレクトリ配下にリポジトリ名のフォルダが作られ、その中にリポジトリ上から取得したファイルがダウンロードされる。
GitHubへpush
まずファイルをローカルリポジトリへadd→commitする。
適当なファイルを作成して、commit。
ユーザー名とメールアドレスを登録しておく必要がある。
$ ll
total 2
-rw-r--r-- 1 Shiragishi 197121 14 6月 16 22:13 hello.txt
-rw-r--r-- 1 Shiragishi 197121 34 6月 16 21:40 README.md $ git add hello.txt $ git config --global user.name "shiragishi" $ git config --global user.email "shiragishi@piyo.com" $ git commit -a -m "First Commit"
[master 428d8ee] First Commit
1 file changed, 1 insertion(+)
create mode 100644 hello.txt
$ git push Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 12 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 288 bytes | 288.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/shiragishi/hello-git.git c8d5442..428d8ee master -> master
pushしたファイルがGitHubのmasterブランチへ追加されていることを確認できる。
SourceTreeのインストール
GitのGUIクライアントの1つで、アトラシアンが提供しているSourceTreeをインストールする。
https://ja.atlassian.com/software/sourcetree
2019/6/16時点のバージョンは3.1.2だった。
インストールにはbitbucketのアカウントが必要みたいなのでインストーラー上のリンクを開き作成する。
その後、インストーラーの「bitbucket server」「bitbucket」の選択では「bitbucket」の方を選択し、後はデフォルトの選択のまま進める。
SourceTreeでgitフォルダを開く
SourceTreeが起動したら、上部メニューのAddからWindows上のチェックアウトしてきているフォルダを選択。
適当にファイルを追加、または更新後、SourceTree上からpushしてGitHubに反映されていれば完了。