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

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

问题描述

如何将源代码从我的计算机导入到我的 GitHub 帐户?

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

推荐答案

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

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. 创建远程仓库,获取git@github.com:/youruser/somename.githttps://github.com/youruser/等URLsomename.git

如果您的本地 GIT 存储库已设置,请跳过第 2 步和第 3 步

在本地,在源的根目录,git init

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

2a.如果您使用 .gitignore 和 README.md 初始化存储库,您应该执行 git pull {url from step 1} 以确保您不会将文件提交到要忽略的源;)

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 ;)

在本地,在初始存储库中添加并提交您想要的内容(对于所有内容,git add . 然后 git commit -m 'initial commit comment')

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

使用名称origin"附加您的远程存储库(就像克隆一样)
git remote add origin [URL From Step 1]

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

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

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