使用gitbash进行代码上传等命令知识点。

1、

错误:

[email protected] /K/cocos2d/yc (master)
$ git push -u origin master
To [email protected]:yangchao0718/cocos2d.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:yangchao0718/cocos2d.git
hint: Updates were rejected because the tip of your current branch is behin
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
错误原因:
github中的README.md文件不在本地代码目录中,即创建工程时创建了readme文件。

解决方法: git pull --rebase origin master    把远程的文件下载到本地,此方法只限远程只有一个readme文件。

然后再:git push -u origin master 即可,其中master值明其是向远程主分支传代码

2、

git pull 后本地没有进行融合(下面执行指令后还是少了忽视文件 .ignore),这时可以进行强制融合,如下:

使用gitbash进行代码上传等命令知识点。

这时候需要进行强制的指令(3个)为:git fetch --allgit reset --hard origin/master git pull

在使用git的过程中,有些时候我们只想要git服务器中的最新版本的项目,对于本地的项目中修改不做任何理会,就需要用到Git pull的强制覆盖。

3、

一次完整的提交过程是:

git add XX 把xx文件添加到暂存区去。

git commit –m “XX” 提交文件 –m 后面的是注释。

git remote add origin XX  关联一个远程库

git push –u(第一次要用-u 以后不需要) origin master 把当前master分支推送到远程库

  注意:一般也会在git add 指令后进行状态查看,其可以看到被添加的新文件,其为:git status

其它常用的指令是:

git status 查看仓库状态

git diff XX 查看XX文件修改了那些内容

git log 查看历史记录

git rm XX 删除XX文件

4、如何把存储的账号密码删除了

使用gitbash进行代码上传等命令知识点。

注意:把这个删了,则会把存储的账号密码删除。