Git For Windows
12.8
1.如果要在Windows下使用Git,可以有两种方式,分别是Cygwin和msysGit。
安装msysGit,下载网址:https://git-for-windows.github.io/
2.设置用户名,邮箱并生成秘钥添加到GitHub网站中。
3.GitHub中新建一个库并在Qtcreator设置git
git push-u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/waldenlakes/Advanced_UCF_shadow_mark.git'
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/waldenlakes/Advanced_UCF_shadow_mark
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Everything up-to-date
Branch 'master' set up to track remote branch 'master' from 'origin'.
git remote rm origin 这个是删除了origin这个远端的仓库和你本地的映射
问题1:
分析:更新被拒绝了,因为远程包含有本地没有的工作。这个通常是另一个仓库push时引起的。在push之前,你可以通过pull先把远程的改变完善。
解决,通过git pull origin master
提示README.md出现冲突,
本地项目内容如下:
remote里的内容如下:
后来就git add README.md,并commit和push
解决问题。
如果想要删除当前工作目录下的文件,
git rm main.txt
git commit -m "del_main.txt"
git push origin master
结果:
删除当前目录下的main.txt,同时会删除remote下的文件。
问题2:
2.1现在remote下的工程,A和B都同时clone到本地,然后,做了修改,比如A对a文件做了修改,B也对a文件做了修改也添加了b文件,如果B先提交了,那么remote是B的状态,然后此时A做提交时,B的状态已与CLONE时的状态发生了变化,此时怎么办?
2.2如果自己先在本地完成了项目,现在想放到github上面,应该怎么做?
首先要先在remote上创建一个新的仓库,不要添加README.md文件。
第二步,在本地目录下右键打开git BASH,打开窗口,然后在窗口中输入git init,使之变成git。
第三步,连接remote上,执行git remote add origin [email protected]:yourName/yourRepo.git
第四步,git add ,git commit -m,git push origin master。添加所有的文件,然后push。
此时目录下如果有个二级目录怎么办?
git add ./test/readme.txt
2.3remote上的项目,想放到本地,直接git clone就OK了。
参考网址:
http://www.runoob.com/w3cnote/git-guide.html【Github 简明教程】
https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013745374151782eb658c5a5ca454eaa451661275886c6000【工作区和暂存区】
http://www.worldhello.net/gotgit/01-meet-git/060-install-on-windows-msysgit.html
https://www.alexleo.click/how-to-install-git-on-windows/
http://blog.****.net/hebbely/article/details/52495073【Qt Creator 中使用 Git / Github】
http://www.jianshu.com/p/8d26730386f3【github上传时出现error: src refspec master does not match any解决办法】