git常用命令與版本回滾

一.git常用命令

Command line instructions

Git global setup
git config --global user.name "accp"
git config --global user.email "[email protected]"

Create a new repository
git clone http://git.buycorp.com/accp/reset-test.git
cd reset-test
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 http://git.buycorp.com/accp/reset-test.git
git add .
git commit -m "Initial commit"
git push -u origin master

Existing Git repository
cd existing_repo
git remote add origin http://git.buycorp.com/accp/reset-test.git
git push -u origin --all
git push -u origin --tags

二.git回到指定版本命令

1.查看master提交版本:git log
D:\reset-test>git log
commit de80d3a2e5498ea30ef35845f65a434d8ebdb697 (HEAD -> master, origin/master_b
ak, origin/master, origin/branch_1.0, branch_1.0)
Author: accp <[email protected]>
Date:   Thu Jan 24 20:38:07 2019 +0800

    <E5><88><A0><E9><99><A4><E6><97><A5><E6><9C><9F>

commit 816184cc9b8cf276900e3340acf956f4151b228f (origin/test)
Author: <E9><99><88><E7><8E><89><E9><BE><99> <[email protected]>
Date:   Thu Jan 24 19:27:56 2019 +0800

    Initial commit

2.回滾master到指定的版本:git reset --hard 816184cc9b8cf276900e3340acf956f4151b228f
D:\reset-test>git reset --hard 816184cc9b8cf276900e3340acf
956f4151b228f
HEAD is now at 816184c Initial commit
                                         ter -> master (forced update)


3.回滾master後推送:git push -f origin master
D:\reset-test>git push -f origin master
Total 0 (delta 0), reused 0 (delta 0)
To http://git.buycorp.com/accp/reset-test.git
 + de80d3a...816184c master -> master (forced update)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章