git cheatsheet

GCS - Git Cheat Sheet

Git file lifecycle

gitFileLifecycle

Initial configuration

1
2
3
git config --global user.name "my name"
git config --global user.email "my email"
git config --global credential store

Branches

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# list branches
git branch # list all branches in local repo. The current active branch will be marked with *
git branch -r # list remote branches
git branch -a # list all branches
# switch branch
git branch <branch-name> # create a new branch
git checkout -b <branch-name> # swith to new-branch and update work erea
git switch <branch-name>
# delete a branch
git branch -d <branch-name> # delete a branch which is already merged
git branch -D <branch-name> # dlete a branch with not checking if it is already merged
# tag
git tag <tag-name> # give a tag for release
# merge
git merge --no-ff -m <message> <branch-name> # new commmit
git squash <branch-name>
# rebase
git rebase <branch-name> # no new commit, just sort of copying all commits to target branch
# reset
git mv


git cheatsheet
http://codingogo.github.com/2024/04/20/git-cheatsheet/
Author
codingogo
Posted on
April 20, 2024
Licensed under