Introduction to git commands#

Updated:

2023-05-05

Super routine of git command#

Hint

When configuration management is performed by one person, at least this routine can be used.

  1. git add .: Stage all changes under the current directory

  2. git commit -m "message": local commit with message

  3. git push: Push commits to remote (github, etc.)

git command for branch#

git branch:

Show list of local branches

git branch -r:

Show list of remote branches

git branch -a:

show a list of all branches

git branch <new branch>:

Make a branch, don’t switch to it

git checkout -b <new branch>:

create a branch and switch

git checkout <existing branch>:

switch to existing branch

git diff <another branch> –name-only:

Show only filenames with changes from <another branch>

git rebase <another branch>:

Rebase with the latest contents of <another branch>

git remote prune origin –dry-run:

Check for remnants of remote branches left locally

git remote prune origin:

Remove local remnants of remote branches

git branch -d <削除ブランチ>:

git branch -d <delete branch>

git branch -D <delete branch>:

Force delete local branch

Basic Routine for Branch Management (Github)#

  1. Create a Branch

  2. Checkout a Branch and Make Changes

  3. Test Locally

  4. Create a Pull Request on Github

  5. Test on Server Environment

  6. Merge if No Issues Found

  7. Delete Branch and End

Hint

Example Routine when Another Change is Made First
  1. git fetch で最新を取り込み

  2. git rebase main としてmainの差分を先に取り込んで変更作業を継続

  3. conflictしたら修正して git rebase –-continue

  4. git push -f origin ブランチ

Reference URL