LoginSignup
0
0

More than 5 years have passed since last update.

【自分用メモ】git入門

Last updated at Posted at 2017-06-24

リモートでの作業

  • git clone [url]
  • リモートレポジトリの表示
    • git remote
    • デフォルトでoriginという名前

リモートレポジトリの追加・削除

  • git remote add [short name] [url]
  • git remote rm [short name]

fetch

リモートから持ってくる。持ってくるだけでマージはしない。

  • git fetch [remote-name]

pull

fetchしてマージもする。

push

  • git push [remote-name] [branch-name]

リモートのoriginに対してローカルのmasterをpushする。

  • git push origin master

ローカルで作成してブランチ(new_branch)をリモートにpushする

  • git push origin new_branch

Tips

  • Updates were rejected because the tip of your current branch is behindでpushに失敗する。
    • git pullする。作業しいてるブランチ名を指定する。
    • git pull (branch name)

やり直し

  • コミット前の編集を元に戻す
    • git checkout -- <file>..
    • git statusを実行すると作業中の変更を破棄するには...として上が表示される
0
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
0
0