Processing math: 100%

Saturday, February 8, 2020

Git command that I should know

Configuration

1
git config --global --edit
This will open the .gitconfig file by our default editor. Make changes, save, and close the editor, changes will take place. To view the changes:
1
git config --global --list

Branches

List out all branches:
1
git branch -a
Create new branch:
1
git branch mynewbranch
switch to new branch:
1
git checkout mynewbranch
Rename a branch (-m for move, as in mv in bash command):
1
git branch -m mynewbranch newbranch
Delete a branch:
1
git branch -d newbranch

Specific branch

git clone a specific branch instead of all the branches and checkout specific one. For example, in my private repo I want to clone the "forth-branch" only, then write:
1
git clone --single-branch --branch forth-branch https://github.com/machingclee/2020-English-Learning-Website.git
without --single-branch the above will fetch all branches and checkout the forth-branch.

P4Merge Configuration

1
2
3
4
5
6
git config --global merge.tool p4merge
git config --global mergetool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"
git config --global mergetool.prompt false
git config --global diff.tool p4merge
git config --global difftool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"
git config --global difftool.prompt false
and git config --global --list to double check the configuration:
1
2
3
4
5
6
7
8
9
10
core.editor="C:\Users\Ching-Cheong Lee\AppData\Local\Programs\Microsoft VS Code\Code.exe" --wait
user.name=James Lee
user.email=machingclee@gmail.com
color.ui=true
merge.tool=p4merge
mergetool.p4merge.path=C:/Program Files/Perforce/p4merge.exe
mergetool.prompt=false
diff.tool=p4merge
difftool.p4merge.path=C:/Program Files/Perforce/p4merge.exe
difftool.prompt=false

No comments:

Post a Comment