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?

基本的なGithub使い方

0
Last updated at Posted at 2026-02-22
-branch:作業の流れを分けること mainでは作業しない、自分のbranchで作業する

-commit:変更内容を保存すること

-push:ローカルの変更をサーバーに送ること

-pull:サーバーの最新の状態を取り込むこと

Git Bashを使う

image.png

commit->pull->push
自分のコードをpushする前に、チーム員が作業したコードをpullする。

(まず今のbranchを確認する:git status)

今までのコードをcommitする:

git add .

git commit -m "commit message"

main branchへ移動する:

git switch main

git pull origin main

*自分のbranchでpullすることも可能


自分のbranchへ戻る:

git switch mybranch

main branchと自分のbranchをmerge:

git merge main

pushする:

git push


似てるように見えるけど違うもの

git merge main vs git merge origin mainの違い

自分のPC(ローカル)にある mainを合わせるか、サーバーにある最新のmainを合わせるかの違いです。

git checkout vs git switchの違い

branch転換:
git checkout branch vs git switch branch(ほぼ同じ)
branch生成+転換:
git checkout -b branch vs git switch -c branch

そしてgit checkout 機能はgit restoreと同じ 

機能の意図を明確にするため、最近はgit checkoutの代わりにgit switchとgit restoreを使っています。

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?