From cf584f84f775cc33f456fa86f2b8837e27775c0f Mon Sep 17 00:00:00 2001 From: Fernando Miguel Date: Sat, 28 May 2022 07:01:14 +0200 Subject: [PATCH] Adding git switch and git restore commands Git has introduced git switch and git restore in order to keep more purposeful scope for the git checkout command which holds more responsibility than simply switch branches. --- tools/git.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/git.sh b/tools/git.sh index c7048d0..9970c7f 100644 --- a/tools/git.sh +++ b/tools/git.sh @@ -31,14 +31,18 @@ git branch # shows all the branches (current branch is s git branch -a # shows all the branches local and remote git branch my-branch # creates my-branch +git checkout -b my-branch # create and switches to my-branch +git switch -c my-branch # create and switches to my-branch git branch -d my-branch # deletes my-branch git checkout my-branch # switches to my-branch +git switch my-branch # switches to my-branch git merge my-branch # merges my-branch to current branch git push origin --delete my-branch # delete remote branch git branch -m # rename the branch git checkout --orphan # checkout a branch with no commit history git branch -vv # list all branches and their upstreams, as well as last commit on branch git branch -a # List all local and remote branches +git restore # Restore specified paths in the working tree git cherry-pick # merge the specified commit git cherry-pick ^.. # pick the entire range of commits where A is older than B ( the ^ is for including A as well )