Now the popular project code uploaded to git, today tried for a long time, and finally successfully uploaded to git up, do something special notes.
Ready to work
Register an account on github, create a warehouse.
Created the warehouse to get it to address:
Start upload
First, create a new folder, copy the item you want to upload to come
Second, the blank space in the folder, right-click on the "Git Bash", enter git command window.
1,
echo " used servlet + jsp log-in operation, providing a verification code, users lock function " >> README.md
Enter the foregoing, the upcoming "servlet + jsp use the log-in operation, providing a verification code, users lock function" write README.md file, README.md automatically created.
2,
touch .gitignore
Creating ignore file, add a line ".gitignore" in the file. That ignore the current .gitignore file. Also ignore files created in the project root directory, add file at the contents
.classpath
.project
/WebRoot/WEB-INF/classes/*
Some projects are dist, build and so do not need to upload a folder, according to the rules can be added to the list.
3, initialization warehouse
the init git // add the following two lines because I have two accounts, a company, one of my own. I am using the individual. config user.name git " youyounanshan " git config user.email " [email protected] "
4,因为远程仓库还是空的,所以我们需要先上传一个文件。
git add README.md //添加文件 git commit -m "first commit" //提交文件 //要上传文件,首先得关联远程仓库,红色部分就是仓库地址 git remote add origin [email protected]:youyounanshan/youdu.git git push -u origin master //推送文件,仓库是空的,第一次得有-u,以后就不用了
刷新你的github,你会发现README.md已经上传到你的仓库了。
5,上传项目
git add . //添加该文件夹下的所有文件 git commit -m "初始导入" git push origin master
至此,项目上传完成。
总结
虽然上传很简单,但是不熟悉还是几个坑的。
1,没有设置密钥,不能上传文件。ssh -T [email protected] 测试是否已经连接成功。
2,忽略文件没有写对,导致不需要上传的文件上传了。