1、码云上创建一个项目 testgit (名字随你)

2、本地创建一个文件夹D:/testgit,然后使用git bash    

3、cd 到本地文件夹中D:/testgit,

4、使用 git init 命令 ,初始化一个git 本地仓库(项目),会在本地创建一个 .git 的文件夹

5、使用git remote add origin https://gitee.com/你的码云用户名/testgit      //添加远程仓库

6、使用 git pull origin master 命令,将码云上的仓库pull到本地文件夹

7、将要上传的文件,添加到刚刚创建的文件夹

8、使用git add . 或者 git add + 文件名 (将文件保存到缓存区)

9、使用git commit -m '描述新添加的文件内容'  (就是注释)   (文件保存到本地仓库)

10、使用git push origin master ,将本地仓库推送到远程仓库

 

报错处理:

错误一:error: failed to push some refs to 'https://gitee.com/XXX_admin/YYYY.git'

将本地项目提交到gitee仓库

处理方法,执行命令:

git pull origin master --allow-unrelated-histories

 

错误二:解决RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large问题

使用SourceTree客户端,向远程仓库推送时:RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large错误!

百度一下:

第一个解决办法是:

在git bash中执行:git config http.postBuffer 524288000

成功后,再次提交,ok。

有些博客,说这个办法不灵,我试可以。

另外,提一下,如果在git bash中执行目录,出现:fatal: Not a git repository (or any of the parent directories): .git

解决办法是在git bash中执行:git init

将本地项目提交到gitee仓库

感谢:http://blog.csdn.net/s1674521/article/details/71844169

第二个解决办法是:

来自http://www.cnblogs.com/lihaiping/p/6021813.html的博客,是使用ssl

 

目前,第一种我试了,可以;第二种,试了,没成功。

 

错误三:git报错:Pull is not possible because you have unmerged files解决方法

  在git pull的过程中,如果有冲突,那么除了冲突的文件之外,其它的文件都会做为staged区的文件保存起来。

重现:

$ git pull

A    Applications/Commerce/BookingAnalysis.java
A    Applications/Commerce/ClickSummaryFormatter.java
M    Applications/CommerceForecasting/forecast/Forecast.java
A    Applications/CommerceForecasting/forecast/ForecastCurveProviderCategory.java
M    Applications/CommerceForecasting/forecast/ForecastProvider.java
M    Applications/CommerceForecasting/forecast/InputPropertyItem.java
......

A    Applications/LocalezeImporter/com/tripadvisor/feeds/SingleMenuLocalezeMatcher.java
A    Applications/LocalezeImporter/com/tripadvisor/feeds/TypeCategory.java

Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
 


通过git status你会发现下面古怪的事情:

[email protected]/ttys000 $ git status
# On branch sns
# Your branch and 'snsconnect/sns' have diverged,
# and have 1 and 52 different commit(s) each, respectively.
#
# Changes to be committed:
#
#    new file:   src/config/features_daodao.ini
#    new file:   src/config/services.xml
#    new file:   src/config/svnroot/hooks/mailer.conf
#    new file:   src/config/svnroot/hooks/mailer.py
#    new file:   src/config/svnroot/hooks/post-commit
#    new file:   src/config/svnroot/hooks/pre-commit
#    new file:   src/config/svnroot/hooks/prerelease_notifications.py
#    new file:   src/config/svnroot/hooks/run_checks.py
…….

# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    _build/
#    css/combined/
#    css/gen/
#    daodao-site.patch
#    daodao-site.patch1
#    js/combined/
#    js/gen/
#    lib/weibo/
#    src/bin/

Pull is not possible because you have unmerged files.

本地的push和merge会形成MERGE-HEAD(FETCH-HEAD), HEAD(PUSH-HEAD)这样的引用。HEAD代表本地最近成功push后形成的引用。MERGE-HEAD表示成功pull后形成的引用。可以通过MERGE-HEAD或者HEAD来实现类型与svn revet的效果。

解决:

1.将本地的冲突文件冲掉,不仅需要reset到MERGE-HEAD或者HEAD,还需要--hard。没有后面的hard,不会冲掉本地工作区。只会冲掉stage区。

git reset --hard FETCH_HEAD

2.git pull就会成功。

 

 


技巧:

1、打开bash方法:

右键项目文件夹,安装好git之后会出现鼠标右键选项

将本地项目提交到gitee仓库

 

2、关于pull

第一次从远程仓库push代码的时候,要注意本地代码的备份;担心本地项目会被清空。

相关文章: