1. 程式人生 > >在github上部署第二個repository

在github上部署第二個repository

是個 branch eject automatic warn find apr example -a

想在github上保存一些平時寫的測試程序,所以就建立了一個repository:https://github.com/commshare/testProgram

建立好之後,怎麽把本地的代碼上傳呢。是個問題。

之前有clone到本地,然後再add 和push到服務器的經歷:

centos6.3 安裝gitosis http://blog.csdn.net/commshare/article/details/17002447
和http://blog.csdn.net/commshare/article/details/16965559 基於centos6.3第一次搭建一個git 服務器
當然,github上我已經有了第一個repository:http://blog.csdn.net/commshare/article/details/14166961 首次部署github上的repository

現在這個是把windows系統裏,本地磁盤的一個文件夾裏頭的文件傳到github上保存。

=============================

參考http://blog.sina.com.cn/s/blog_63eb3eec0101cf6x.html

參考 http://www.cnblogs.com/findingsea/archive/2012/08/27/2654549.html

參考 http://artori.us/git-github-usage/

參考 http://lazynight.me/2898.html

(1)安裝git的工具,github的工具被墻了,所以裝 這個TortoiseGit:http://msysgit.github.com/

下載地址 : http://code.google.com/p/tortoisegit/

裝好之後,右鍵就不同了。

(2)在所要上次文件夾裏頭點擊上面的git init here

(3)打開git bash ,準備 ssh key。

ssh-keygen -t rsa -C "[email protected]"


存在這裏:

要把id_rsa.pub傳到github上,做為一個新的key。

Welcome to Git (version 1.8.4-preview20130916)

Run ‘git help git‘ to display the help index.
Run ‘git help <command>‘ to display help for specific commands.


ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ ssh-keygen -t rsa -C "c*********[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/ZhangBin/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/ZhangBin/.ssh/id_rsa.
Your public key has been saved in /c/Users/ZhangBin/.ssh/id_rsa.pub.

ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)

(4)加入key到github上。

測試是否成功:

$ ssh -T [email protected]
The authenticity of host ‘github.com (192.30.252.130)‘ can‘t be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘github.com,192.30.252.130‘ (RSA) to the list of know
n hosts.
Hi commshare! You‘ve successfully authenticated, but GitHub does not provide she
ll access.

(5)加入新的賬戶(用戶名和郵箱)

ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git config --global user.name "zhangbin"


ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git config --global user.email


ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$


ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git config --global user.email "c####[email protected]"

(6) 加入遠程的github上的倉庫,文件就是傳入到這個倉庫裏頭的。

進入要上傳的倉庫,右鍵git bash,添加遠程地址:

ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)

$ git remote add orign [email protected]:c*******e/testProgram.git


ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git pull
fatal: No remote repository specified. Please, specify either a URL or a
remote name from which new revisions should be fetched.


ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git pull origin master
fatal: ‘origin‘ does not appear to be a git repository
fatal: Could not read from remote repository.


Please make sure you have the correct access rights
and the repository exists.

還是寫成origin吧,

ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git remote add origin [email protected]:commshare/testProgram.git

(7)成功的從遠程倉庫取出數據

ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git pull origin master
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From github.com:commshare/testProgram
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master

(8)給遠程倉庫傳入數據

ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git add ./testTHIS.cpp

這個a 出錯了:

ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git commit -m -a "test this pointer of C++ "
error: pathspec ‘test this pointer of C++ ‘ did not match any file(s) known to g
it.


ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git commit -m "test this pointer of C++ "
[master 172c3c8] test this pointer of C++
1 file changed, 27 insertions(+)
create mode 100644 testTHIS.cpp


ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from ‘matching‘ to ‘simple‘. To squelch this message
and maintain the current behavior after the default changes, use:


git config --global push.default matching


To squelch this message and adopt the new behavior now, use:


git config --global push.default simple


See ‘git help config‘ and search for ‘push.default‘ for further information.
(the ‘simple‘ mode was introduced in Git 1.7.11. Use the similar mode
‘current‘ instead of ‘simple‘ if you sometimes use older versions of Git)


Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 584 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:commshare/testProgram.git
3a7460a..172c3c8 master -> master


ZhangBin@ZHANGBIN-PC /E/codeReocrdi (master)
$

======================================

然後,我又使用我的ubuntu12.04的zhangbin用戶向這個倉庫傳入代碼:

zhangbin@Ubuntu32:~/codeStore/testcode$ ls
FIFO testBool testBool.c testlseek testlseek.c ts_length ts_length.c
zhangbin@Ubuntu32:~/codeStore/testcode$ git init
Initialized empty Git repository in /home/zhangbin/codeStore/testcode/.git/

zhangbin@Ubuntu32:~/codeStore/testcode$ git remote add origin [email protected]:commshare/testProgram.git
zhangbin@Ubuntu32:~/codeStore/testcode$ git add testlseek

報錯,好像是說先要加入新的用戶:

zhangbin@Ubuntu32:~/codeStore/testcode$ git commit -m "test lseek for getting a file‘s length"
[master (root-commit) 7c752bc] test lseek for getting a file‘s length
Committer: ZhangBin@Ubuntu32 <zhangbin@Ubuntu32.(none)>
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 [email protected]


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 100755 testlseek
zhangbin@Ubuntu32:~/codeStore/testcode$ git config --global user.name "zhangbin"
zhangbin@Ubuntu32:~/codeStore/testcode$ git config --global user.email "我的郵箱@gmail.com"

還是報錯,加入了用戶之後,似乎應該先add?但實際上,上一個add在沒有加入用戶的時候,已經add成功了。

所以這下面沒有testlseek了。


zhangbin@Ubuntu32:~/codeStore/testcode$ git commit -m "test lseek for getting a file‘s length"
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# FIFO/
# testBool
# testBool.c
# testlseek.c
# ts_length
# ts_length.c
nothing added to commit but untracked files present (use "git add" to track)

直接這樣報錯:好像是要指定分支的:
zhangbin@Ubuntu32:~/codeStore/testcode$ git push
Warning: Permanently added the RSA host key for IP address ‘192.30.252.131‘ to the list of known hosts.
To [email protected]:commshare/testProgram.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘[email protected]:commshare/testProgram.git‘
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. ‘git pull‘) before pushing again. See the
‘Note about fast-forwards‘ section of ‘git push --help‘ for details.
zhangbin@Ubuntu32:~/codeStore/testcode$ git add ./testlseek.c ./testlseek commit -m "test lseek for getting a file‘s length"
error: unknown switch `m‘
usage: git add [options] [--] <filepattern>...


-n, --dry-run dry run
-v, --verbose be verbose


-i, --interactive interactive picking
-p, --patch select hunks interactively
-e, --edit edit current diff and apply
-f, --force allow adding otherwise ignored files
-u, --update update tracked files
-N, --intent-to-add record only the fact that the path will be added later
-A, --all add changes from all tracked and untracked files
--refresh don‘t add, only refresh the index
--ignore-errors just skip files which cannot be added because of errors
--ignore-missing check if - even missing - files are ignored in dry run

加入新的文件:
zhangbin@Ubuntu32:~/codeStore/testcode$ git add ./testlseek.c ./testlseek

註釋成功:
zhangbin@Ubuntu32:~/codeStore/testcode$ git commit -m "test lseek for getting a file‘s length"
[master ed859ef] test lseek for getting a file‘s length
1 file changed, 49 insertions(+)
create mode 100644 testlseek.c

push失敗:要指定分支
zhangbin@Ubuntu32:~/codeStore/testcode$ git push
To [email protected]:commshare/testProgram.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘[email protected]:commshare/testProgram.git‘
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. ‘git pull‘) before pushing again. See the
‘Note about fast-forwards‘ section of ‘git push --help‘ for details.


zhangbin@Ubuntu32:~/codeStore/testcode$ git push origin master
To [email protected]:commshare/testProgram.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘[email protected]:commshare/testProgram.git‘
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. ‘git pull‘) before pushing again. See the
‘Note about fast-forwards‘ section of ‘git push --help‘ for details.

貌似拉下來也失敗:
zhangbin@Ubuntu32:~/codeStore/testcode$ git pull
warning: no common commits
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 3 (delta 0)
Unpacking objects: 100% (6/6), done.
From github.com:commshare/testProgram
* [new branch] master -> origin/master
You asked me to pull without telling me which branch you
want to merge with, and ‘branch.master.merge‘ in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. ‘git pull <repository> <refspec>‘).
See git-pull(1) for details.


If you often merge with the same branch, you may want to
use something like the following in your configuration file:
[branch "master"]
remote = <nickname>
merge = <remote-ref>


[remote "<nickname>"]
url = <url>
fetch = <refspec>


See git-config(1) for details.

這麽拉就好了:
zhangbin@Ubuntu32:~/codeStore/testcode$ git pull origin master
From github.com:commshare/testProgram
* branch master -> FETCH_HEAD
Merge made by the ‘recursive‘ strategy.
README.md | 2 ++
testTHIS.cpp | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
create mode 100644 README.md
create mode 100644 testTHIS.cpp

這麽推也是好的:

zhangbin@Ubuntu32:~/codeStore/testcode$ git push origin master
Counting objects: 9, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 3.93 KiB, done.
Total 8 (delta 0), reused 0 (delta 0)
To [email protected]:commshare/testProgram.git
172c3c8..3414346 master -> master
zhangbin@Ubuntu32:~/codeStore/testcode$

===========刪掉一個文件

git rm --cached filename
git commit -m "hehe"
git push origin branch

======================後來老是遇到這些問題,就是push不上去,必須先pull===================

root@Ubuntu32:/home/zhangbin/STM/testcode# vi test_StrDup.c
root@Ubuntu32:/home/zhangbin/STM/testcode# gcc -o test_StrDup test_StrDup.c
test_StrDup.c: In function ‘strDup’:
test_StrDup.c:6:16: warning: incompatible implicit declaration of built-in function ‘strlen’ [enabled by default]
test_StrDup.c:9:10: warning: incompatible implicit declaration of built-in function ‘memcpy’ [enabled by default]
root@Ubuntu32:/home/zhangbin/STM/testcode# ./test_StrDup
after copy is [zhangbinhometown]
root@Ubuntu32:/home/zhangbin/STM/testcode# git add test_StrDup.c
root@Ubuntu32:/home/zhangbin/STM/testcode# git commit -m "字符串復制,來自live555"
[master d6ab4d6] 字符串復制,來自live555
1 file changed, 18 insertions(+)
create mode 100644 test_StrDup.c
root@Ubuntu32:/home/zhangbin/STM/testcode# git push
To [email protected]:commshare/testProgram.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘[email protected]:commshare/testProgram.git‘
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. ‘git pull‘) before pushing again. See the
‘Note about fast-forwards‘ section of ‘git push --help‘ for details.
root@Ubuntu32:/home/zhangbin/STM/testcode# git push origin master
To [email protected]:commshare/testProgram.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘[email protected]:commshare/testProgram.git‘
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. ‘git pull‘) before pushing again. See the
‘Note about fast-forwards‘ section of ‘git push --help‘ for details.
root@Ubuntu32:/home/zhangbin/STM/testcode# git push git pull
fatal: ‘git‘ does not appear to be a git repository
fatal: The remote end hung up unexpectedly
root@Ubuntu32:/home/zhangbin/STM/testcode# git push
^C
root@Ubuntu32:/home/zhangbin/STM/testcode# git pull
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 13 (delta 5), reused 11 (delta 3)
Unpacking objects: 100% (13/13), done.
From github.com:commshare/testProgram
8bd6223..39097c5 master -> origin/master
You asked me to pull without telling me which branch you
want to merge with, and ‘branch.master.merge‘ in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. ‘git pull <repository> <refspec>‘).
See git-pull(1) for details.


If you often merge with the same branch, you may want to
use something like the following in your configuration file:
[branch "master"]
remote = <nickname>
merge = <remote-ref>


[remote "<nickname>"]
url = <url>
fetch = <refspec>


See git-config(1) for details.
root@Ubuntu32:/home/zhangbin/STM/testcode# git push origin master
To [email protected]:commshare/testProgram.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘[email protected]:commshare/testProgram.git‘
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. ‘git pull‘) before pushing again. See the
‘Note about fast-forwards‘ section of ‘git push --help‘ for details.
root@Ubuntu32:/home/zhangbin/STM/testcode# git pull origin master
From github.com:commshare/testProgram
* branch master -> FETCH_HEAD
Merge made by the ‘recursive‘ strategy.
testIFDEFINE.c | 26 ++++++++++++++++++++++++++
testUpasting.cpp | 37 +++++++++++++++++++++++++++++++++++++
testUpastingVirtual.cpp | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 100 insertions(+)
create mode 100644 testIFDEFINE.c
create mode 100644 testUpasting.cpp
create mode 100644 testUpastingVirtual.cpp
root@Ubuntu32:/home/zhangbin/STM/testcode# git push origin master
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 759 bytes, done.
Total 5 (delta 2), reused 0 (delta 0)
To [email protected]:commshare/testProgram.git
39097c5..e0fa03f master -> master
root@Ubuntu32:/home/zhangbin/STM/testcode#

######add 2014 01 13 #################################

後來,又新建立了一個java的測試工程保存路徑。

加入了一些android的工程:

root@Ubuntu32:/home/zhangbin/ffmpeg/android/ndk-samples# git init
Initialized empty Git repository in /home/zhangbin/ffmpeg/android/ndk-samples/.git/
root@Ubuntu32:/home/zhangbin/ffmpeg/android/ndk-samples# git remote add origin https://github.com/commshare/meTestJavaProgram.git
root@Ubuntu32:/home/zhangbin/ffmpeg/android/ndk-samples# ls
bitmap-plasma hello-jni native-activity san-angeles
gles3jni hello-neon native-audio Teapot
HelloComputeNDK module-exports native-media test-libstdc++
hello-gl2 MoreTeapots native-plasma two-libs
root@Ubuntu32:/home/zhangbin/ffmpeg/android/ndk-samples# git add hello-jni
root@Ubuntu32:/home/zhangbin/ffmpeg/android/ndk-samples# git commit -m "use hello-jni project to test fprintf replacement for android platform "
[master (root-commit) 038d666] use hello-jni project to test fprintf replacement for android platform
38 files changed, 462 insertions(+)
create mode 100755 hello-jni/.classpath
create mode 100755 hello-jni/.project
create mode 100755 hello-jni/.settings/org.eclipse.jdt.core.prefs
create mode 100644 hello-jni/AndroidManifest.xml
create mode 100755 hello-jni/bin/AndroidManifest.xml
create mode 100755 hello-jni/bin/HelloJni.apk
create mode 100755 hello-jni/bin/classes.dex
create mode 100755 hello-jni/bin/classes/com/example/hellojni/BuildConfig.class
create mode 100755 hello-jni/bin/classes/com/example/hellojni/HelloJni.class
create mode 100755 hello-jni/bin/classes/com/example/hellojni/R$attr.class
create mode 100755 hello-jni/bin/classes/com/example/hellojni/R$string.class
create mode 100755 hello-jni/bin/classes/com/example/hellojni/R.class
create mode 100755 hello-jni/bin/dexedLibs/annotations-bf65d065d2bf11dc7706959d18f5bc41.jar
create mode 100755 hello-jni/bin/resources.ap_
create mode 100755 hello-jni/gen/com/example/hellojni/BuildConfig.java
create mode 100755 hello-jni/gen/com/example/hellojni/R.java
create mode 100755 hello-jni/jni/Android.mk
create mode 100755 hello-jni/jni/hello-jni.c
create mode 100644 hello-jni/libs/armeabi/gdb.setup
create mode 100755 hello-jni/libs/armeabi/gdbserver
create mode 100755 hello-jni/libs/armeabi/libhello-jni.so
create mode 100755 hello-jni/obj/local/armeabi/libhello-jni.so
create mode 100644 hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o
create mode 100644 hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d
create mode 100755 hello-jni/project.properties
create mode 100644 hello-jni/res/values/strings.xml
create mode 100644 hello-jni/src/com/example/hellojni/HelloJni.java
create mode 100755 hello-jni/tests/.classpath
create mode 100755 hello-jni/tests/.project
create mode 100755 hello-jni/tests/.settings/org.eclipse.jdt.core.prefs
create mode 100644 hello-jni/tests/AndroidManifest.xml
create mode 100755 hello-jni/tests/bin/AndroidManifest.xml
create mode 100755 hello-jni/tests/bin/classes/com/example/hellojni/HelloJniTest.class
create mode 100755 hello-jni/tests/bin/classes/com/example/hellojni/tests/BuildConfig.class
create mode 100755 hello-jni/tests/bin/jarlist.cache
create mode 100755 hello-jni/tests/gen/com/example/hellojni/tests/BuildConfig.java
create mode 100755 hello-jni/tests/project.properties
create mode 100644 hello-jni/tests/src/com/example/hellojni/HelloJniTest.java
root@Ubuntu32:/home/zhangbin/ffmpeg/android/ndk-samples# git push origin master
Username for ‘https://github.com‘:
Password for ‘:
To https://github.com/commshare/meTestJavaProgram.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘https://github.com/commshare/meTestJavaProgram.git‘
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. ‘git pull‘) before pushing again. See the
‘Note about fast-forwards‘ section of ‘git push --help‘ for details.


root@Ubuntu32:/home/zhangbin/ffmpeg/android/ndk-samples# git pull origin master
warning: no common commits
remote: Reusing existing pack: 17, done.
remote: Total 17 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (17/17), done.
From https://github.com/commshare/meTestJavaProgram
* branch master -> FETCH_HEAD
Merge made by the ‘recursive‘ strategy.
testWriteByteArray/.classpath | 6 ++
testWriteByteArray/.project | 17 ++++
.../.settings/org.eclipse.jdt.core.prefs | 11 +++
testWriteByteArray/bin/writeArray.class | Bin 0 -> 1540 bytes
testWriteByteArray/home.txt | 1 +
testWriteByteArray/src/writeArray.java | 93 ++++++++++++++++++++
6 files changed, 128 insertions(+)
create mode 100644 README.md
create mode 100644 testWriteByteArray/.classpath
create mode 100644 testWriteByteArray/.project
create mode 100644 testWriteByteArray/.settings/org.eclipse.jdt.core.prefs
create mode 100644 testWriteByteArray/bin/writeArray.class
create mode 100644 testWriteByteArray/home.txt
create mode 100644 testWriteByteArray/src/writeArray.java
root@Ubuntu32:/home/zhangbin/ffmpeg/android/ndk-samples# git push origin master
To https://github.com/commshare/meTestJavaProgram.git
1710880..e4eb82c master -> master
root@Ubuntu32:/home/zhangbin/ffmpeg/android/ndk-samples#
---------------------
作者:commshare
來源:CSDN
原文:https://blog.csdn.net/commshare/article/details/17078093
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!

在github上部署第二個repository