zoukankan      html  css  js  c++  java
  • 在github上部署第二个repository

    想在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 "your_email@youremail.com"


    存在这里:

    要把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*********e.zhang@gmail.com"
    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 git@github.com
    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####e.zhang@gmail.com"

    (6) 加入远程的github上的仓库,文件就是传入到这个仓库里头的。

    进入要上传的仓库,右键git bash,添加远程地址:

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

    $ git remote add orign git@github.com: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 git@github.com: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 git@github.com: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 git@github.com: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 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 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 git@github.com:commshare/testProgram.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'git@github.com: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 git@github.com:commshare/testProgram.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'git@github.com: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 git@github.com:commshare/testProgram.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'git@github.com: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 git@github.com: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 git@github.com:commshare/testProgram.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'git@github.com: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 git@github.com:commshare/testProgram.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'git@github.com: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 git@github.com:commshare/testProgram.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'git@github.com: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 git@github.com: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
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    P4091 [HEOI2016/TJOI2016]求和(第二类斯特林数+NTT)
    CF960G Bandit Blues(第一类斯特林数)
    loj#2542. 「PKUWC2018」随机游走(树形dp+Min-Max容斥)
    mysql修改原始密码
    MySQL基础命令小结
    pip安装python包出错:Could not find a version that satisfies the requirement skimage (from versions: )
    python 安装whl文件
    python中使用anaconda对不平衡数据的处理包imblearn的安装
    数据分析-合辑
    No module named ‘sklearn.model_selection解决办法
  • 原文地址:https://www.cnblogs.com/whowhere/p/10043073.html
Copyright © 2011-2022 走看看