1. 程式人生 > >git操作及版本回退

git操作及版本回退

Command line instructions

Git global setup

git config --global user.name "z**11"
git config --global user.email "zha**om"

Create a new repository

git clone [email protected]*hsi.git
cd cehsi
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder

cd existing_folder
git init
git remote add origin [email protected]*cehsi.git
git add .
git commit
git push -u origin master

Existing Git repository

cd existing_repo
git remote add origin [email protected]*ehsi.git
git push -u origin --all
git push -u origin --tags

檢視提交歷史:git log

檢視命令歷史:git reflog

回退到上一個版本:git reset --hard HEAD^

回退到上n個版本:git reset --hard HEAD~n

回退到指定版本:git reset --hard commitId