用eclipse提交代码到github
1. 创建账号
2. 创建工程仓库
3. 创建仓库honey后,访问页面(https://github.com/automvc/honey)如下。还没发现有任何提交文件。url格式如下:https://github.com/{账号名称}/{仓库名}
页面的内容如下:
…or create a new repository on the command line
echo "# honey" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/automvc/honey.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/automvc/honey.git
git push -u origin master
…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
4. 参照:…or create a new repository on the command line
提交一个文件,激活工程所在仓库.
https://github.com/automvc/honey.git 是仓库网址,要替换为自己的。
切换到工程目录,输入以下命令:
git init
git add README
git commit -m "first commit"
git remote add origin https://github.com/automvc/honey.git
git push -u origin master
D:\JavaWeb\workspaceGit\Honey>git init
Initialized empty Git repository in D:/JavaWeb/workspaceGit/Honey/.git/
D:\JavaWeb\workspaceGit\Honey>git add README
D:\JavaWeb\workspaceGit\Honey>git commit -m "first commit"
[master (root-commit) 95e2121] first commit
1 file changed, 2 insertions(+)
create mode 100644 README
D:\JavaWeb\workspaceGit\Honey>git remote add origin https://github.com/automvc/honey.git
D:\JavaWeb\workspaceGit\Honey>git push -u origin master
Username for 'https://github.com': honeysoft@126.com
Password for 'https://honeysoft@126.com@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/automvc/honey.git/'
注:若输错密码可以重新执行命令
D:\JavaWeb\workspaceGit\Honey>git push -u origin master
Username for 'https://github.com': honeysoft@126.com
Password for 'https://honeysoft@126.com@github.com':
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 265 bytes | 265.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/automvc/honey.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
5. 创建.gitignore文件:
将不用提交的文件或文件夹忽略,避免提交到仓库。
内容如下:
/.settings
/target
6.
用Eclipse提交工程。
工程右击选: 共享工程。
点击完成。
多了许多问号:
提交文件:
完成,点OK.
刷新网址,发现已成功提交文件。
7.
以后有Eclipse有文件修改,就可以直接用Eclipse提交文件到git了。
修改文件,文件多了一个>大于号箭头,表示有修改。
右击文件,选Team->Commit即可修改。
是不是比用DOS窗口直接,方便!
注:README.md是md格式的说明文件。若是README则显示的为文本格式。
欢迎关注:https://github.com/automvc/bee或https://github.com/automvc/honey
<Bee 是一个十分钟即可上手的JAVA ORM框架>