打开终端输入git,看看是否已经安装上git,如果没有的话输入命令sudo apt-get install git
在安装完成之后可以输入git--verson,会出现git的版本信息,然后可以输入
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
创建一个空目录
$ mkdir learngit
$ cd learngit
$ pwd
/Users/michael/learngit
创建库
$ git init
Initialized empty Git repository in /Users/michael/learngit/.git/
niuxushuo@niuxushuo-Inspiron-3437:~/WebstormProjects/CartList$ git status //
位于分支 master
您的分支领先 'origin/master' 共 1 个提交。
(使用 "git push" 来发布您的本地提交)
要提交的变更:
(使用 "git reset HEAD <文件>..." 以取消暂存)
新文件: js/cart.js
尚未暂存以备提交的变更:
(使用 "git add <文件>..." 更新要提交的内容)
(使用 "git checkout -- <文件>..." 丢弃工作区的改动)
修改: .idea/workspace.xml
niuxushuo@niuxushuo-Inspiron-3437:~/WebstormProjects/CartList$ git add .
niuxushuo@niuxushuo-Inspiron-3437:~/WebstormProjects/CartList$ git status //寻找新变更的文件
位于分支 master
您的分支领先 'origin/master' 共 1 个提交。
(使用 "git push" 来发布您的本地提交)
要提交的变更:
(使用 "git reset HEAD <文件>..." 以取消暂存)
修改: .idea/workspace.xml
新文件: js/cart.js
niuxushuo@niuxushuo-Inspiron-3437:~/WebstormProjects/CartList$ git commit -m "新增home.js文件" //
[master f7b1983] 新增home.js文件
2 files changed, 17 insertions(+), 5 deletions(-)
create mode 100644 js/cart.js
niuxushuo@niuxushuo-Inspiron-3437:~/WebstormProjects/CartList$ git push
Username for 'https://gitee.com': niuxushuo-123
Password for 'https://niuxushuo-123@gitee.com':
对象计数中: 9, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (9/9), 完成.
写入对象中: 100% (9/9), 1.26 KiB | 1.26 MiB/s, 完成.
Total 9 (delta 4), reused 0 (delta 0)
remote: Powered by Gitee.com
To https://gitee.com/niuxushuo-123/CartList.git
b02ee13..f7b1983 master -> master
2.git push origin master -f,强制上传