0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

gitコマ

Last updated at Posted at 2025-07-10

よく使うやつ

  git add .
  git commit -m" コメント "
  git push リポジトリ名

初めてpush時、リモートリポ追加

  git init
  
  git add .
  
  git commit -m "Initial commit: next_purchase API + virtualenv + requirements"

  git branch -M main

  git remote add origin <リポジトリURL>

  git push -u origin main

リモートリポ追加コマンドしてないと..

  cannnot find origin main
プルリク マージ

 gh pr create --base main --head ブランチ名 --title "Add integration tests" --body "結合テスト追加"

 gh pr merge ブランチ名 --merge --admin

 git checkout main
 
 git pull origin main
merge取り消す
git revert <コミットID>
いらんファイルコミットしちゃった
git reset --soft HEAD~1

git reset <不要ファイル>

必要ファイルのみでコミットし直す
git commit -m "必要なファイルだけコミット"
いらんファイルaddした
git reset <不要ファイル>
いらんファイルpushした
git rm <不要ファイル>
git commit -m "Remove unwanted file"
git push origin <ブランチ名>
ブランチ名間違え、間違いブランチにいる
  git brach
ブランチ名間違え、間違いブランチにいない
  git brach

  git checkout 別ブランチ

  git branch -d 間違えたブランチ名

  git checkout -b 正しいブランチ名
git statusエラー
 リモートがローカルに反映されてない
 Your branch is ahead of 'origin/main'  git push


 リモートを取り込まなきゃいけない + pushが拒否された
 Your branch is behind 'origin/main'  git pull origin main 

 Untracked files:にadd したいファイルがあった
 git add ファイル名

git checkout -- ファイル名 使いどき

addしてないファイルを元に戻したい

ファイルを間違えて編集しちゃった

新しい関数作ったけど、ファイルadd予定 ない

ファイル編集したけど、その編集を元に戻したい

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?