LoginSignup
0
0

More than 3 years have passed since last update.

初心者用Github コマンド集

Last updated at Posted at 2020-04-19

はじめに

仕事でGithubを使用することが多くなったので,今まで使用した基本コマンドを初心者なりにまとめました.

基本コマンド集

ローカルレポジトリの設定

#ローカルレポジトリ作成
git init

#ローカルとリモートレポジトリの紐付け
git remote add origin <リモートレポジトリのURL>

ファイルのpushまでの流れ

git add ~~.py   #特定のファイルをpushしたい時
git add .       #ディレクトリ内の全てのファイルをpushしたい時
git commit -m 'comment'
git push origin <branch-name>

branch周り

#branch切る
git branch <new_branch>
#branchの移動
git checkout <移動先branch>
#上記をまとめて
git checkout -b <new_branch>
#branch名変更
git branch -m <old_branch> <new_branch>
#branch削除
git branch -d <remove_branch>

pullした変更の内容を別branchに反映させたい時

git pull origin <remoteで変更があったbranch>
git checkout <変更を取り入れたいbranch>

@変更を取り入れたいbranch
git merge origin <remoteで変更があったbranch>

(おまけ) commitをgitのissueと紐付けする

仕事などで,githubを使用して開発する際,Issueを立てることが多いと思うが,githubのIssueとcommitを紐づける方法がある.
以下のようにコメントの冒頭にIssueのIDを書くと,github上で,Issueとの結びつけが行われる.

git commit -m "#1 init"
image.png
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