git 將本地專案提交到第三方簡單操作

牙小木木發表於2016-08-05

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完成就好啦~

相關文章