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 
Date:   Thu Jan 24 20:38:07 2019 +0800

    <88><99><97><9C><9F>

commit 816184cc9b8cf276900e3340acf956f4151b228f (origin/test)
Author: <99><88><8E><89><99> 
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)

 

你可能感兴趣的:(git常用命令,git,git版本回滚,技术类)