GitとGitHubの使い方、導入〜Pushまでよく使うものまとめ
Gitリポジトリを初期化→コミット
$ git init $ git add -A $ git commit -m "Initialize repository"
▼コミット時、「dquote> 」が発生
・「"」(ダブルクォーテーション)のせい(dquote = double quotation の略)
→半角の”を付ければ解消 lawrence-twin.hateblo.jp
一つのタスクをこなす毎にこまめにコミットする
$ git commit -am "[コメント]"
GitHubにプッシュ
②次に以下のコマンド
$ git remote add origin https://github.com/<GitHubアカウント名>/sample_app.git $ git push -u origin <ブランチ名>
うまくいかなかったらSSHに変更
以下「SSH認証でgithub上のリモートリポジトリにpushできるようにする」を参照
yoshiyoshifujii.hatenablog.com
リモートレポジトリをローカルにコピーする
$ git clone git・・・ $ git clone http・・・
現在の状態を確認
$ git status
ブランチを新規作成して切り替える
git checkout -b 新ブランチ名
コミットの記録を見る
$ git log
最終コミットまでリセット
$ git reset --hard HEAD
cloneしたリポジトリを別リポジトリとしてリモートにpushする
qiita.com ▼リモート元の確認方法
$git remote -v
結果↓
origin クローンしたいリポジトリのURL (fetch) origin クローンしたいリポジトリのURL (push)
cloneしたリポジトリをGitHubの別リポジトリで管理する方法
https://reasonable-code.com/repository-copy/
# 事前に新しいリポジトリをGitHubで作成しておく # 古いリポジトリをクローンする $ git clone https://github.com/xxx/old-repository.git $ cd old-repository # 古いリポジトリのGitの更新情報を削除する $ rm -rf .git # 新しいリポジトリを新規作成する $ git init $ git add . $ git commit -m "Initial commit" $ git remote add origin https://github.com/xxx/new-repository.git $ git push -u origin master
参考
忘れがちなGitコマンドまとめ qiita.com
Githubに画像を貼り付けたい時
①GitHub Issue を開き
②開いた Issue に、貼り付けたい画像をドラッグ&ドロップすると画像を貼り付けるためのタグが生成される