git命令

来源:互联网 发布:linux socket bind 编辑:程序博客网 时间:2024/06/05 07:50
1.填写用户名和邮箱作为标识
git config --global user.name "user-tzw"


git config --global user.email "869233763@qq.com"


2.初始化git
git init


3.查看工作区状态信息
git  status


4.提交至暂存区
git add  file(文件名字)


5.提交至本地仓库
git commit   -m  “the first time”(双引号中是注释)


6.提交至远程仓库
git push


7.查看最近提交的历史记录
git log 


8.第一次提交的话,需要关联仓库
git remote add origin https://github.com/tzw-user/Practice-project.git  (https://github.com/tzw-user/Practice-project.git  仓库地址名)


9.把当前master分支推送到远程库
git push -u origin master (第一次要用-u 以后不需要)


10.提交至远程仓库可能会出现的问题
错误:GitHub远程仓库中的README.md文件不在本地仓库中。(error: failed to push some refs to 'https://github.com/tzw-user/Practice-project.git') 
解决方案:git pull --rebase origin master (将README.md同步)
          git push -u origin master


11.回退至上一个版本
git reset –hard HEAD^
原创粉丝点击