145 words
1 minutes
[Git] Basic Git setup and usage
Table of Contents
Links
Download the git from https://git-scm.com/downloads
Config
- SSH
Set the ssh from Github:
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
ssh-keygen
cat .ssh/id_rsa.pub
- Local config
For windows, install the nano from choco
is the easiest way. Install choco
with node.js
first.
choco install -y nano
git config --global core.editor "nano"
git config --global user.name "Peter"
git config --global user.email "peter123@gmail.com"
Command
Basic command for:
- Git adding file changes
- Git commit current added file
- Git pull for any curretn branch changes
- Git push if current branch is up-to-date
git add . # git add -A
git commit -m "message"
git pull
git push
branches
Create a new branch
git checkout -b <brance_name>
git checkout -b development
Goto exist branch
git checkout <brance_name>
git checkout development
Undo git add
The following command is used to revoke a git add .
in CLI.
Undo all
Assume you have git add
couple times.
git reset
Undo one
undo one git add
git reset <file>
Undo one commit only
Used to revoke one git commit
with soft reset.
git reset --soft HEAD~1