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-03-09

エンジニアになってそんなに間もないですが、業務でよく使うGitコマンドを紹介していきます!

git pull --rebase origin main

このコマンドは、git push する前に使います。

イメージとしては、事前にgithubにある最新のコードをpushする前に反映させてコンフリクトを防げるというのがメリットかと思います。
--rebeseすると、今のコミットの前にgithubの内容を差し込んでくれます。

githubの最新の状態をローカルに反映するときに何かと多用しているコマンドになります。

git checkout -b branch名

特定のブランチから新しいブランチを切るときに使っています。
だいたいは、developブランチなどからfeature/〇〇などのブランチを切るときに使います。
ここら辺は、git workflow(https://www.atlassian.com/ja/git/tutorials/comparing-workflows/gitflow-workflow )を見てみてください。

git checkout branch名

既存のブランチに移るときに使います。

git push origin branch名

githubにブランチを上げるときに使います。
githubにブランチを上げた後に、githubにてマージ先にプルリクエストを投げています。
また、新しいブランチをgithubに作るときにも使っています。
例:developブランチ、stagingブランチ、release/v1.0.0ブランチを作るときなど

git add .

ファイルの変更内容の登録コマンド

git commit -m "コメント内容"

git add . をした後にコミットをコメント付きで行います。
この後に、git push origin ブランチ名 をすることでgithubに上げます。

git stush

git checkout ブランチ名を行う前に、コミット前の変更があるときにこのコマンドを使って一時保存します。

git stash apply

git stashしたものをもとに戻します。この場合、最新のstashしたものが元に戻ります。

以上です。

0
0
1

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?