git 将本地项目提交到第三方简单操作

1、已有本地项目文件夹

2.在1的文件夹下git init

$ git init
Initialized empty Git repository in C:/usertb/cart1.4.0.0/.git/

发现多了master字样

tb@tb MINGW64 /c/usertb/cart1.4.0.0 (master)

创建个文件演示下

$ touch read.u

tb@tb MINGW64 /c/usertb/cart1.4.0.0 (master)

添加文件到本地

$ git add read.u
tb@tb MINGW64 /c/usertb/cart1.4.0.0 (master)

提交到本地,写个注释

$ git commit -m 'just fc'
[master (root-commit) 27cf218] just fc
 Committer: unknown <tb>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 0 insertions(+), 0 deletions(-)

 create mode 100644 read.u

3.去gitoschina conding.net github 等创建分支

比如链接为http://git.oschina.net/mysina…

4、本地基础添加远程分支,名字我叫cartnote

tb@tb MINGW64 /c/usertb/cart1.4.0.0 (master)
$ git remote add cartnote http://git.oschina.net/mysina/cart_note

5、试着push上去

$ git push cartnote master
To http://git.oschina.net/mysina/cart_note
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'http://git.oschina.net/mysina/cart_note'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

6、他那意思可能是要pull下before push,听他的

$ git pull
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.
tb@tb MINGW64 /c/usertb/cart1.4.0.0 (master)
$ git pull cartnote
warning: no common commits
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From http://git.oschina.net/mysina/cart_note
 * [new branch]      master     -> cartnote/master
You asked to pull from the remote 'cartnote', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

好了吧?

7、还是有错,咋回事?

tb@tb MINGW64 /c/usertb/cart1.4.0.0 (master)
$ git pull cartnote
You asked to pull from the remote 'cartnote', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

tb@tb MINGW64 /c/usertb/cart1.4.0.0 (master)

我们需要指定下pull的url

$ git pull http://git.oschina.net/mysina/cart_note
From http://git.oschina.net/mysina/cart_note
 * branch            HEAD       -> FETCH_HEAD
Already up-to-date!
Merge made by the 'recursive' strategy.

8、好,这次应该可以

到现在第一个测试文件已经上去了,我们接下来把项目文件扔上去

$ git push cartnote master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 339 bytes | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
To http://git.oschina.net/mysina…
10120ee..9f7c085 master -> master

9、添加所有

git add *
git commit -m ‘add*’

git push cartnote master
Counting objects: 4247, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4122/4122), done.
Writing objects:  28% (1196/4247), 1.51 MiB | 178.00 KiB/s

9.5 wtf,hung up。。

$ git push cartnote master
Counting objects: 4247, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4122/4122), done.
error: unable to rewind rpc post data - try increasing http.postBuffer
error: RPC failed; curl 56 Recv failure: Connection was reset
The remote end hung up unexpectedly4.98 MiB | 24.00 KiB/sfatal:
Writing objects: 100% (4247/4247), 14.69 MiB | 561.00 KiB/s, done.
Total 4247 (delta 1081), reused 0 (delta 0)
fatal: The remote end hung up unexpectedly
Everything up-to-date
看看这错误。。。。

10.等着9.5完成就好啦~

    原文作者:牙小木木
    原文地址: https://segmentfault.com/a/1190000006185325
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞