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.
git add .
: Stage all changes under the current directorygit commit -m "message"
: local commit with messagegit 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)#
Create a Branch
Checkout a Branch and Make Changes
Test Locally
Create a Pull Request on Github
Test on Server Environment
Merge if No Issues Found
Delete Branch and End
Hint
- Example Routine when Another Change is Made First
git fetch
で最新を取り込みgit rebase main
としてmainの差分を先に取り込んで変更作業を継続conflictしたら修正して
git rebase –-continue
git push -f origin ブランチ
Reference URL