Git 使用命令

$ git init
$ git remote add origin https://github.com/sunbey80/demo.git

$ git status
$ git add . $ git commit -m "html files created 20160308 16:08"
$ git push origin master
$ git push -u origin master

设置本地账号

$ git config --global user.name "xuhaiyan"
$ git config --global user.email "haiyan.xu.vip@gmail.com"

生成秘钥

$ ssh-keygen -t rsa -C “haiyan.xu.vip@gmail.com”

忽略文件

echo "node_modules" >> .gitignore

------------------------------------------------

q:出现无法提交代码

failed to push some refs to

a:解决方案:

git pull --rebase origin master

------------------------------------------------

q:合并后[git merge origin/master]怎么撤销

a:解决方案:

git reset --hard HEAD~

 

q:撤出暂存区

a:解决方案:

git reset HEAD -- .

 

q:还原文件

checkout对应版本。格式为 git checkout <hash> <filename>
例如命令行中输入
git checkout d98a0f565804ba639ba46d6e4295d4f787ff2949 src/main/main.js

 

posted @ 2016-03-08 16:22  sunbey80  阅读(204)  评论(0编辑  收藏  举报