git bash 提交代码到github

1,需要先在github上创建一个Repository,这一步不使用git bash,而是直接在网页上操作

2,然后依次使用bash命令

cd 到工作目录

git init

git status

git add . (如果不是只有更新,则可以指定add filename或者add --all强制所有文件)

git commit -m "anywords"

git remote add origin https://github.com/yanly2013/test.git  (这句不是每次都需要)

git push -u origin master

如果连接成功,需要输入用户名密码,即可

3,其中git remote add origin https://github.com/yanly2013/test.git有可能出现失败remote origin already exists. (fatal ERROR:Repository  not found)

解决方法为将config文件中的将文件中的 [remote “origin"]部分去掉!

 

更新远程代码到本地只需要git pull即可

有时出现提交不了代码,发现是新换一台电脑光安装git bash还不够,还需要按照他提示提交who you are,即邮件地址和用户名

 

posted @ 2014-06-26 23:51  精灵2014  阅读(421)  评论(0编辑  收藏  举报