Git cheat sheet: Difference between revisions

From misc notes
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
github で repository つくったら手順がでてくる
github で repository つくったら手順がでてくる


  mkdir hoge
<syntaxhighlight lang="bash" enclose="div">
  cd hoge
mkdir hoge
  git init
cd hoge
  touch README.md
git init
  git add README.md
touch README.md
  git commit -m 'first commit'
git add README.md
  git remote add origin git@github.com:fuga/hoge.git
git commit -m 'first commit'
  git push -u origin master
git remote add origin git@github.com:fuga/hoge.git
 
git push -u origin master
</syntaxhighlight>


編集後
編集後
git add README.md
<syntaxhighlight lang="bash" enclose="div">
git commit -m 'message here'
git add README.md
git push
git commit -m 'message here'
git push
</syntaxhighlight>


rename
rename
git mv README.md README
<syntaxhighlight lang="bash" enclose="div">
git commit -m 'message here'
git mv README.md README
git push
git commit -m 'message here'
git push
</syntaxhighlight>


fork して放置したリポジトリを元のリポジトリと合わせる
fork して放置したリポジトリを元のリポジトリと合わせる
git pull 元のリポジトリ master
<syntaxhighlight lang="bash" enclose="div">
git push
git pull 元のリポジトリ master
git push
</syntaxhighlight>


ブランチを切る
ブランチを切る
git checkout -b my_new_branch
<syntaxhighlight lang="bash" enclose="div">
git checkout -b my_new_branch
</syntaxhighlight>


ブランチを push
ブランチを push
git push origin my_new_branch
<syntaxhighlight lang="bash" enclose="div">
git push origin my_new_branch
</syntaxhighlight>
 
プルリクエストのパターン
<syntaxhighlight lang="text" enclose="div">
github上でfork
そいつを git clone
</syntaxhighlight>
<syntaxhighlight lang="bash" enclose="div">
git checkout -b 作業内容がよく分かるブランチ名
</syntaxhighlight>

Revision as of 16:53, 21 April 2016

github で repository つくったら手順がでてくる

mkdir hoge
cd hoge
git init
touch README.md
git add README.md
git commit -m 'first commit'
git remote add origin git@github.com:fuga/hoge.git
git push -u origin master

編集後

git add README.md
git commit -m 'message here'
git push

rename

git mv README.md README
git commit -m 'message here'
git push

fork して放置したリポジトリを元のリポジトリと合わせる

git pull 元のリポジトリ master
git push

ブランチを切る

git checkout -b my_new_branch

ブランチを push

git push origin my_new_branch

プルリクエストのパターン

github上でfork
そいつを git clone
git checkout -b 作業内容がよく分かるブランチ名