How can I associate local unversioned code to git remote repository?

前端 未结 4 1001
别跟我提以往
别跟我提以往 2020-12-31 00:24

I need to associate a clean unversioned code to an existing git remote repository.

I explain better my situation. My project is moved from svn to git. I have a svn

4条回答
  •  既然无缘
    2020-12-31 01:05

    I would commit your working directory to ensure that it exists in history before fetching. (ensure you are in the projects root folder)

    git init
    git add -A
    git commit -m "my latest'
    

    now we have it

    git remote add origin url-to-your-remote
    git fetch origin
    

    now we have the history from the remote

    git reset origin/master
    

    now our current commit is the latest from the remote

    git add -A
    git commit -m "Committed my state"
    

    now we use our current working directory as the snapshot for the next commit.

    git push -u origin master
    

    push up your changes and track the branch.

    the key is the reset command with no --hard option. It keeps your working folder the same while pointing the branch to what you got from the remote.

提交回复
热议问题