Reference: https://www.liaoxuefeng.com/wiki/896043488029600
This is a tutorial to learn the basic commands of git. Three functions of git and github:
- remote repository
- version control
- branch management
echo "# StableAA" >> README.md
git config --global user.name 'datake'
git config --global user.email 'ajksunke@foxmail.com'
git init
git add . / git add ***
5. commit files to the working repository (after multiply adding files), from "staged" to "unmodified" status
git commit -m "log information, e.g., first commit"
git remote add origin 'repository address'
git branch -M main
git pull --rebase origin main
git push -u origin main (first time)
git push origin main (later)
git status
git diff ###(file name)
git log (--pretty=oneline)
4. go back to previous version, note that HEAD is the current version, ^ means the last version, ^^ indicates the second last version. HEAD is a pointer, pointing to a specific version
git reset --hard HEAD^
(git reset --hard "commit id(several first numbers is OK)")
git reflog
git checkout -- filename
git rm ***(file name)
git branch
git branch dev
git checkout dev
git checkout master git merge dev
git branch -d dev
Here are two important figures about git.