How can I find the location of origin/master in git, and how do I change it?

前端 未结 13 550
悲哀的现实
悲哀的现实 2020-12-02 03:33

I\'m a Git newbie. I recently moved a Rails project from Subversion to Git. I followed the tutorial here: http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-yo

13条回答
  •  佛祖请我去吃肉
    2020-12-02 04:04

    I am struggling with this problem and none of the previous answers tackle the question as I see it. I have stripped the problem back down to its basics to see if I can make my problem clear.

    I create a new repository (rep1), put one file in it and commit it.

    mkdir rep1
    cd rep1
    git init
    echo "Line1" > README
    git add README
    git commit -m "Commit 1"
    

    I create a clone of rep1 and call it rep2. I look inside rep2 and see the file is correct.

    cd ~
    git clone ~/rep1 rep2
    cat ~/rep2/README
    

    In rep1 I make a single change to the file and commit it. Then in rep1 I create a remote to point to rep2 and push the changes.

    cd ~/rep1
    
    git remote add rep2 ~/rep2
    git push rep2 master
    

    Now when I go into rep2 and do a 'git status' I get told I am ahead of origin.

    # On branch master
    # Your branch is ahead of 'origin/master' by 1 commit.
    #
    # Changes to be committed:
    #   (use "git reset HEAD ..." to unstage)
    #
    #   modified:   README
    #
    

    README in rep2 is as it was originally, before the second commit. The only modifications I have done are to rep1 and all I wanted to do was push them out to rep2. What is it I am not grasping?

提交回复
热议问题