git上传项目到github
用Eclipse建了git项目后,通过git bash上传项目到github,当然前提远程库是存在的。
1.生成公钥
·ssh-keygen -t rsa -C "bottomheater94@gmail.com"
2.将公钥(即~/.ssh/id_rsa.pub)然后放到github上
在账户中设置
新建ssh keys
3.连接测试
ssh -T git@github.com
注意参数大写T,正确输出Hi bottomheater/tudu_list! You've successfully authenticated, but GitHub does not provide shell access.
小写t会输出PTY allocation request failed on channel 0
,坑
同时github上也会(钥匙图案绿了)
也可以将公钥只部署到项目中
4.本地库关联到远程库
git remote add tudu git@github.com:bottomheater/tudu.git
5.查看本地未提交的文件
git status
如果本地库有文件未提交,又暂时不想提交到远程库中,保存修改到stash
git stash
6.假如远程库有文件,先合并到本地库中
git pull --rebase tudu master
7.上传项目
git push -u tudu master
8.恢复本地未提交的已修改文件
git stash pop
附上完整过程
wang@Bottom MINGW32 ~/tudu (master)
$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '[192.30.253.122]:443' to the list of known hosts.
Hi bottomheater! You've successfully authenticated, but GitHub does not provide shell access.
wang@Bottom MINGW32 ~/tudu (master)
$ git remote add tudu git@github.com:bottomheater/tudu.git
wang@Bottom MINGW32 ~/tudu (master)
$ git stash
No local changes to save
wang@Bottom MINGW32 ~/tudu (master)
$ git pull --rebase tudu master
From github.com:bottomheater/tudu
* branch master -> FETCH_HEAD
* [new branch] master -> tudu/master
First, rewinding head to replay your work on top of it...
Applying: [initial]Base on tudu list 2.3
Applying: [initial]add the file forgotten to upload.
Applying: [modify]add chinese
wang@Bottom MINGW32 ~/tudu (master)
$ git push -u tudu master
Counting objects: 645, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (411/411), done.
Writing objects: 100% (645/645), 2.75 MiB | 138.00 KiB/s, done.
Total 645 (delta 135), reused 639 (delta 132)
remote: Resolving deltas: 100% (135/135), completed with 1 local object.
To git@github.com:bottomheater/tudu.git
ec9c4ed..3897359 master -> master
Branch master set up to track remote branch master from tudu.
wang@Bottom MINGW32 ~/tudu (master)
$ git stash pop
On branch master
Your branch is up-to-date with 'tudu/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: tudu/pom.xml
modified: tudu/tudu-presentation/tudu-dwr/src/main/webapp/WEB-INF/web.xml
Untracked files:
(use "git add <file>..." to include in what will be committed)
tudu/.classpath
tudu/.project
tudu/.settings/
tudu/target/
tudu/tudu-core/.classpath
tudu/tudu-core/.gitignore
tudu/tudu-core/.project
tudu/tudu-core/.settings/
tudu/tudu-core/.springBeans
tudu/tudu-core/ajcore.20170805.210526.567.txt
tudu/tudu-core/ajcore.20170805.210526.773.txt
tudu/tudu-core/ajcore.20170805.210526.793.txt
tudu/tudu-core/ajcore.20170805.214418.159.txt
tudu/tudu-core/ajcore.20170805.214418.179.txt
tudu/tudu-core/ajcore.20170805.214418.267.txt
tudu/tudu-presentation/.project
tudu/tudu-presentation/.settings/
tudu/tudu-presentation/tudu-dwr/.classpath
tudu/tudu-presentation/tudu-dwr/.project
tudu/tudu-presentation/tudu-dwr/.settings/
tudu/tudu-presentation/tudu-dwr/.springBeans
tudu/tudu-presentation/tudu-dwr/src/main/code/
tudu/tudu-presentation/tudu-dwr/src/main/webapp/WEB-INF/jsp/test.jsp
tudu/tudu-presentation/tudu-dwr/src/main/webapp/WEB-INF/spring/springmvc-controller.xml
tudu/tudu-presentation/tudu-dwr/target/
tudu/tudu-presentation/tudu-flex/.classpath
tudu/tudu-presentation/tudu-flex/.project
tudu/tudu-presentation/tudu-flex/.settings/
tudu/tudu-presentation/tudu-flex/target/
tudu/tudu-presentation/tudu-gwt/.classpath
tudu/tudu-presentation/tudu-gwt/.project
tudu/tudu-presentation/tudu-gwt/.settings/
tudu/tudu-presentation/tudu-gwt/.springBeans
tudu/tudu-presentation/tudu-gwt/target/
tudu/tudu-presentation/tudu-jsf/.classpath
tudu/tudu-presentation/tudu-jsf/.gitignore
tudu/tudu-presentation/tudu-jsf/.project
tudu/tudu-presentation/tudu-jsf/.settings/
tudu/tudu-presentation/tudu-portlet/.classpath
tudu/tudu-presentation/tudu-portlet/.project
tudu/tudu-presentation/tudu-portlet/.settings/
tudu/tudu-presentation/tudu-portlet/target/
tudu/tudu-presentation/tudu-springmvc/.classpath
tudu/tudu-presentation/tudu-springmvc/.project
tudu/tudu-presentation/tudu-springmvc/.settings/
tudu/tudu-presentation/tudu-springmvc/target/
tudu/tudu-presentation/tudu-springwebflow/.classpath
tudu/tudu-presentation/tudu-springwebflow/.project
tudu/tudu-presentation/tudu-springwebflow/.settings/
tudu/tudu-presentation/tudu-springwebflow/target/
tudu/tudu-ws/.project
tudu/tudu-ws/.settings/
tudu/tudu-ws/tudu-axis-client/.classpath
tudu/tudu-ws/tudu-axis-client/.gitignore
tudu/tudu-ws/tudu-axis-client/.project
tudu/tudu-ws/tudu-axis-client/.settings/
tudu/tudu-ws/tudu-axis/.classpath
tudu/tudu-ws/tudu-axis/.gitignore
tudu/tudu-ws/tudu-axis/.project
tudu/tudu-ws/tudu-axis/.settings/
tudu/tudu-ws/tudu-xfire-jaxws2/.classpath
tudu/tudu-ws/tudu-xfire-jaxws2/.project
tudu/tudu-ws/tudu-xfire-jaxws2/.settings/
tudu/tudu-ws/tudu-xfire/.classpath
tudu/tudu-ws/tudu-xfire/.gitignore
tudu/tudu-ws/tudu-xfire/.project
tudu/tudu-ws/tudu-xfire/.settings/
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (2d0a0bfaa30459216d427bc60ce40d593513ed70)
wang@Bottom MINGW32 ~/tudu (master)
$ git status
On branch master
Your branch is up-to-date with 'tudu/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: tudu/pom.xml
modified: tudu/tudu-presentation/tudu-dwr/src/main/webapp/WEB-INF/web.xml
Untracked files:
(use "git add <file>..." to include in what will be committed)
tudu/.classpath
tudu/.project
tudu/.settings/
tudu/target/
tudu/tudu-core/.classpath
tudu/tudu-core/.gitignore
tudu/tudu-core/.project
tudu/tudu-core/.settings/
tudu/tudu-core/.springBeans
tudu/tudu-core/ajcore.20170805.210526.567.txt
tudu/tudu-core/ajcore.20170805.210526.773.txt
tudu/tudu-core/ajcore.20170805.210526.793.txt
tudu/tudu-core/ajcore.20170805.214418.159.txt
tudu/tudu-core/ajcore.20170805.214418.179.txt
tudu/tudu-core/ajcore.20170805.214418.267.txt
tudu/tudu-presentation/.project
tudu/tudu-presentation/.settings/
tudu/tudu-presentation/tudu-dwr/.classpath
tudu/tudu-presentation/tudu-dwr/.project
tudu/tudu-presentation/tudu-dwr/.settings/
tudu/tudu-presentation/tudu-dwr/.springBeans
tudu/tudu-presentation/tudu-dwr/src/main/code/
tudu/tudu-presentation/tudu-dwr/src/main/webapp/WEB-INF/jsp/test.jsp
tudu/tudu-presentation/tudu-dwr/src/main/webapp/WEB-INF/spring/springmvc-controller.xml
tudu/tudu-presentation/tudu-dwr/target/
tudu/tudu-presentation/tudu-flex/.classpath
tudu/tudu-presentation/tudu-flex/.project
tudu/tudu-presentation/tudu-flex/.settings/
tudu/tudu-presentation/tudu-flex/target/
tudu/tudu-presentation/tudu-gwt/.classpath
tudu/tudu-presentation/tudu-gwt/.project
tudu/tudu-presentation/tudu-gwt/.settings/
tudu/tudu-presentation/tudu-gwt/.springBeans
tudu/tudu-presentation/tudu-gwt/target/
tudu/tudu-presentation/tudu-jsf/.classpath
tudu/tudu-presentation/tudu-jsf/.gitignore
tudu/tudu-presentation/tudu-jsf/.project
tudu/tudu-presentation/tudu-jsf/.settings/
tudu/tudu-presentation/tudu-portlet/.classpath
tudu/tudu-presentation/tudu-portlet/.project
tudu/tudu-presentation/tudu-portlet/.settings/
tudu/tudu-presentation/tudu-portlet/target/
tudu/tudu-presentation/tudu-springmvc/.classpath
tudu/tudu-presentation/tudu-springmvc/.project
tudu/tudu-presentation/tudu-springmvc/.settings/
tudu/tudu-presentation/tudu-springmvc/target/
tudu/tudu-presentation/tudu-springwebflow/.classpath
tudu/tudu-presentation/tudu-springwebflow/.project
tudu/tudu-presentation/tudu-springwebflow/.settings/
tudu/tudu-presentation/tudu-springwebflow/target/
tudu/tudu-ws/.project
tudu/tudu-ws/.settings/
tudu/tudu-ws/tudu-axis-client/.classpath
tudu/tudu-ws/tudu-axis-client/.gitignore
tudu/tudu-ws/tudu-axis-client/.project
tudu/tudu-ws/tudu-axis-client/.settings/
tudu/tudu-ws/tudu-axis/.classpath
tudu/tudu-ws/tudu-axis/.gitignore
tudu/tudu-ws/tudu-axis/.project
tudu/tudu-ws/tudu-axis/.settings/
tudu/tudu-ws/tudu-xfire-jaxws2/.classpath
tudu/tudu-ws/tudu-xfire-jaxws2/.project
tudu/tudu-ws/tudu-xfire-jaxws2/.settings/
tudu/tudu-ws/tudu-xfire/.classpath
tudu/tudu-ws/tudu-xfire/.gitignore
tudu/tudu-ws/tudu-xfire/.project
tudu/tudu-ws/tudu-xfire/.settings/
no changes added to commit (use "git add" and/or "git commit -a")
wang@Bottom MINGW32 ~/tudu (master)
$