在github创建工程

    今天在github上创建一个工程,与 本地同步,遇到了问题.特此记录一下..

1 在github上创建一个仓库 比如 https://github.com/zhenghui/guava

2 在本地创建maven工程(看自己是否需要是maven工程)..

3 到本地项目目录下 执行 

写道
D:\workspace\guava\guava>git init
Initialized empty Git repository in D:/workspace/guava/guava/.git/

 4 关联github上的仓库.

写道
D:\workspace\guava\guava>git remote add origin https://github.com/zhenghui/guava

5 新增和提交代码.

写道
D:\workspace\guava\guava>git add src pom.xml
warning: LF will be replaced by CRLF in pom.xml.
The file will have its original line endings in your working directory.

D:\workspace\guava\guava>git commit -m 'init'
[master (root-commit) ad099d2] 'init'
warning: LF will be replaced by CRLF in pom.xml.
The file will have its original line endings in your working directory.
2 files changed, 19 insertions(+)
create mode 100644 pom.xml
create mode 100644 src/main/java/Test.java

6 push代码到github 

写道
D:\workspace\guava\guava>git push -u origin master
Username for 'https://github.com': zhenghui
Password for 'https://[email protected]':
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (7/7), 687 bytes, done.
Total 7 (delta 0), reused 0 (delta 0)
To https://github.com/zhenghui/guava
* [new branch] master -> master
Branch master set up to track remote branch master from origin.

差不多就是这样..以后每次代码新增,都是循环第五步和第六步..其他没啥说的..总结一下还是挺容易的.

如果在github上创建了文件(比如创建了一个README.md),这样在push之前需要进行一次pull操作.

写道
D:\workspace\guava\guava-example>git pull https://github.com/zhenghui/guava mas
ter
From https://github.com/zhenghui/guava
* branch master -> FETCH_HEAD
Merge made by the 'recursive' strategy.
README.md | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 README.md

猜你喜欢

转载自chenjingbo.iteye.com/blog/1878927