将现有源代码导入GitHub [英] Import existing source code to GitHub

查看:186
本文介绍了将现有源代码导入GitHub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将源代码从我的电脑导入到我的GitHub帐户?

如果您有本地源代码你想添加到一个新的远程新的git仓库而不用'克隆'远程,首先执行以下操作(我经常这样做 - 你在bitbucket / github中创建远程空仓库,然后推送你的源代码)


  1. 创建远程存储库,并获取诸如 git@github.com:/youruser/somename.git https://github.com/youruser/somename.git



    如果您已经设置了本地GIT仓库,跳过步骤2和步骤3

    ,在你的源代码根目录下, git init



    2a。如果您使用.gitignore和README.md初始化回购库,则应该执行 git pull {步骤1中的url} ,以确保您不会提交源文件你想忽略;)

  2. 在本地,添加并提交你想要的东西在你的初始回购(任何东西, git add。

  3. / code>然后 git commit -m'初始提交评论'


    $ b

  4. 将您的远程仓库与名称'origin'相关联(如克隆会执行的操作)

    git remote add origin [URL From Step 1]


  5. 执行 git pull origin master 来拉远程分支,使它们同步。
  6. 推高主分支(将主分支更改为其他分支的其他分支):

    git push origin master c $ c>


How can I import source code from my computer to my GitHub account?

解决方案

If you've got local source code you want to add to a new remote new git repository without 'cloning' the remote first, do the following (I often do this - you create your remote empty repository in bitbucket/github, then push up your source)

  1. Create the remote repository, and get the URL such as git@github.com:/youruser/somename.git or https://github.com/youruser/somename.git

    If your local GIT repo is already set up, skips steps 2 and 3


  2. Locally, at the root directory of your source, git init

    2a. If you initialize the repo with a .gitignore and a README.md you should do a git pull {url from step 1} to ensure you don't commit files to source that you want to ignore ;)

  3. Locally, add and commit what you want in your initial repo (for everything, git add . then git commit -m 'initial commit comment')


  4. to attach your remote repo with the name 'origin' (like cloning would do)
    git remote add origin [URL From Step 1]

  5. Execute git pull origin master to pull the remote branch so that they are in sync.
  6. to push up your master branch (change master to something else for a different branch):
    git push origin master

这篇关于将现有源代码导入GitHub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆