search

Home  >  Q&A  >  body text

github - git command line, how to synchronize an existing local directory with a remote repository with a different name

For example, if there is a directory aaa locally, and a warehouse named bbb has been established on remote github, how do I establish a synchronization relationship? --Is it possible not to change the directory name locally?

The stupid method I am using now is to use git clone **/bbb.git to the local, and then copy the files in aaa into the bbb warehouse, and then synchronize. This must change the directory name. And troublesome.

怪我咯怪我咯2768 days ago749

reply all(3)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-02 09:47:12

    Passedgit remote add命令增加远程仓库。
    git remote add origin **/bbb.git

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-02 09:47:12

    You don’t have to change the directory name, just use the following command in the local warehouse aaa:

    git remote add origin <远程仓库的url>

    Hereorigin是远程仓库url的别名,可以使用比较常用的origin, you can also specify it freely. One thing to note is that if the remote warehouse already has content, it will be more troublesome. Therefore, when building a remote warehouse, it is best not to add any README, LICENSE and other files, otherwise it will cause the local to be unable to be pushed to the remote, because the two have no common history.

    In addition, if the original poster’s method is feasible, you can also customize the warehouse name when using the git clone command:

    git clone <远程仓库url> <自定义的仓库名字>

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-02 09:47:12

    git remote add origin -u **/bbb.git

    reply
    0
  • Cancelreply