- 查看当前状态
git status
,查看当前哪些代码未提交,及文件修改状态yusian@Work-SianMac:~/Documents/Project/Vue/demo34% git status On branch developer Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: .eslintrc.js modified: package.json modified: src/App.vue deleted: src/components/HelloWorld.vue modified: src/main.js modified: src/plugins/element.js modified: src/router/index.js deleted: src/views/About.vue deleted: src/views/Home.vue modified: yarn.lock Untracked files: (use "git add <file>..." to include in what will be committed) src/components/home.vue src/components/login.vue vue.config.js no changes added to commit (use "git add" and/or "git commit -a")
- 查看分支
git branch
yusian@Work-SianMac:~/Documents/Project/Vue/demo34% git branch * developer master
- 添加文件
git add .
,如果添加单个文件后面跟文件名,如果添加所有文件使用通配符.
yusian@Work-SianMac:~/Documents/Project/Vue/demo34% git add . yusian@Work-SianMac:~/Documents/Project/Vue/demo34% git status On branch developer Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: .eslintrc.js modified: package.json modified: src/App.vue deleted: src/components/HelloWorld.vue new file: src/components/home.vue new file: src/components/login.vue modified: src/main.js modified: src/plugins/element.js modified: src/router/index.js deleted: src/views/About.vue deleted: src/views/Home.vue new file: vue.config.js modified: yarn.lock
[……]
Tag Archives: github
Leave a reply
如何在MacOS中安装git,使本地项目与gitHub同步
1、下载安装git
1.1、https://www.git-scm.com/ 对于MacOS来讲一般不需要安装,系统已经自带了该程序;
2、在github上创建一个项目
2.1、申请github帐号,完善个人资料什么的就带过来;
2.2、在浏览器的右上角有个“+”图标,第一个选项“New repository”就是创建一个新的项目;
2.3、点击该选项后会打开一个项目创建的基本信息输入页面,如下图所示,基本说明在图有也有标记;
3、在新项目中添加部署证书
3.1、什么是部署证书?当你在提交或同步代码时,服务器怎么知道你是合法用户?所以该证书就是本地机器和服务端相互信任的一种验证机制;
3.2、打开终端,生成本地证书
1 2 3 | SianMac2:~ yusian$ ssh-keygen -t rsa -b 4096 -C "yusian@163.com" Generating public/private rsa key pair. Enter file in which to save the key (/Users/yusian/.ssh/id_rsa): |
3.3、默认都按回车即可,最终会生成id_rsa和id_rsa.pub两个文件(友情提示不要在照抄,路径中有你当前机器的用户名)
3.4、用文本编辑器打开id_rsa.pub或在终端中直接cat /Users/yusian/.ssh/id_rsa.pub,再将文本或输出的内容复制3.5、在第2步中创建了一个项目,进入该项目的主页,打开项目设置(最后那个Setting选项),参照下图所示
3.6、在Deloy Key中点击右边的Add Deloy Key,Title随便写,用于标识这个证书是谁的,Key的内容就是刚刚你复制的那段文本,而下面那个Allor write access指是否可写,如果你要提交代码那就要勾选,如果你只同步那就不勾选;
3.7、一切准备工作都搞完![……]