说起来尴尬,好几年前就搞了github建了仓库,当时玩得还有点6,后来一直的公司都是svn,自己业务项目也没玩,都忘了要怎么提交代码到自己的仓库了。
这边再来一波记录吧。
一、配置用户名
git config --global user.name "Mona Lisa"
确认已修改:
git config --global user.name
二、本地配置邮箱
git config --global user.email "[email protected]"
确认已修改:
git config --global user.email
三、修改github上邮箱,保持一致
https://help.github.com/articles/setting-your-commit-email-address-on-github/
四、https克隆自己的github仓库
本地找个目录用:
git clone url(拷贝的地址)
五、修改文件,提交
修改文件,切换到项目根路径下,打开git bash,执行:
git add .
git commit -m "Add existing file"
git push origin master
(这步没让我输密码,不知道为啥)
然后我再去github上,文件已经修改了。
ps:
针对本地项目已经存在,要关联到github仓库的情况:
1 C:\Users\Gaoyu\Documents\WeChat Files\qiyepretty\FileStorage\File\2019-06\tomcat
2 -saxtest>git init
3 Initialized empty Git repository in C:/Users/Gaoyu/Documents/WeChat Files/qiyepr
4 etty/FileStorage/File/2019-06/tomcat-saxtest/.git/
5
6 C:\Users\Gaoyu\Documents\WeChat Files\qiyepretty\FileStorage\File\2019-06\tomcat
7 -saxtest>git remote add origin https://github.com/cctvckl/tomcat-saxtest.git
8
9
10
11 C:\Users\Gaoyu\Documents\WeChat Files\qiyepretty\FileStorage\File\2019-06\tomcat
12 -saxtest>git add .
13 warning: LF will be replaced by CRLF in saxtest.iml.
14 The file will have its original line endings in your working directory.
15
16 C:\Users\Gaoyu\Documents\WeChat Files\qiyepretty\FileStorage\File\2019-06\tomcat
17 -saxtest>git commit -m "Add existing file"
18 [master (root-commit) 66f9392] Add existing file
19 18 files changed, 532 insertions(+)
20 create mode 100644 pom.xml
21 create mode 100644 saxtest.iml
22 create mode 100644 src/main/java/com/coder/Coder.java
23 create mode 100644 src/main/java/com/coder/DigesterTest.java
24 create mode 100644 src/main/java/com/coder/Girl.java
25 create mode 100644 src/main/java/com/coder/GirlFriendHandler.java
26 create mode 100644 src/main/java/com/coder/SaxTest.java
27 create mode 100644 src/main/java/com/coder/TwoTuple.java
28 create mode 100644 src/main/resources/girlfriend.xml
29 create mode 100644 target/classes/META-INF/services/IShout
30 create mode 100644 target/classes/com/coder/Coder.class
31 create mode 100644 target/classes/com/coder/DigesterTest$1.class
32 create mode 100644 target/classes/com/coder/DigesterTest.class
33 create mode 100644 target/classes/com/coder/Girl.class
34 create mode 100644 target/classes/com/coder/GirlFriendHandler.class
35 create mode 100644 target/classes/com/coder/SaxTest.class
36 create mode 100644 target/classes/com/coder/TwoTuple.class
37 create mode 100644 target/classes/girlfriend.xml
38
39 C:\Users\Gaoyu\Documents\WeChat Files\qiyepretty\FileStorage\File\2019-06\tomcat
40 -saxtest>git push origin master
41 Counting objects: 31, done.
42 Delta compression using up to 8 threads.
43 Compressing objects: 100% (22/22), done.
44 Writing objects: 100% (31/31), 15.38 KiB | 2.56 MiB/s, done.
45 Total 31 (delta 1), reused 0 (delta 0)
46 remote: Resolving deltas: 100% (1/1), done.
47 To https://github.com/cctvckl/tomcat-saxtest.git
48 * [new branch] master -> master
ps:如果要删除的话,用下面的命令:
// 删除 target 文件夹
git rm -r target