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コマンド集

0
Last updated at Posted at 2026-10-30

よく使うGitコマンド集:beginner:

リポジトリ作成:new:

1. リモートリポジトリ作成

2. ローカルリポジトリ作成

# リポジトリ作成
git init
# 初回コミット
git commit --allow-empty -m "first commit"
# デフォルトブランチ名変更
git branch -M main

3. リモートリポジトリと紐づけ

# リモートリポジトリとの紐づけ
git remote add origin <Githubのリモートリポジトリ>
# 更新(マージのためにvimが開いたら:wq)
git pull --allow-unrelated-histories
# ブランチの紐づけ
git branch --set-upstream-to=origin/main
git push

差分取込:arrows_counterclockwise:

mainをfeatureに取り込んで最新化する

# マージ
git switch main
git pull origin main
git merge main
git push origin feature
# リベース(git履歴が綺麗だが高度)
git switch main
git pull origin main
git rebase main
git push origin feature --force-with-lease

--force-with-leaseするまえにfetchやpullしないこと。
でないとgitが最新状態になったと誤解して--force-with-leaseなのに強制的に上書きできてしまう。

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?