我如何从我的计算机导入源代码到我的GitHub帐户?
当前回答
其中一条评论提到了使用GitHub GUI,但它没有提供任何具体的使用帮助,并注意到大多数(如果不是所有的话)答案只在命令提示符下有用。
如果你想使用GitHub GUI,你可以按照以下步骤:
Click the "+" button and choose "Add Local Repository" Navigate to the directory with your existing code and click the "Add" button. You should now be prompted to "Create a new local Git repository here" so click the "Yes" button. Add your "Commit Summary" and "Extended description" as desired. By default, all of your files should selected with checkmarks already. Click the "Commit & Sync" button. Now you will be prompted to add the name and description of your project as well as which account to push it to (if you have multiple). Click the "Push Repository" button
在旋转GitHub图标后,您的源代码将属于本地存储库,并在您的GitHub帐户上推送/同步到远程存储库。所有这些都假设您之前已经设置了GitHub GUI、您的GitHub帐户和SSH密钥。
其他回答
如果你有本地源代码,你想添加到一个新的远程新git存储库,而不“克隆”远程,执行以下操作(我经常这样做-你在bitbucket/github中创建你的远程空存储库,然后推送你的源代码)
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 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 ;) Locally, add and commit what you want in your initial repo (for everything, git add . then git commit -m 'initial commit comment') to attach your remote repo with the name 'origin' (like cloning would do) git remote add origin [URL From Step 1] Execute git pull origin master to pull the remote branch so that they are in sync. to push up your master branch (change master to something else for a different branch): git push origin master
打开你的GitHub仪表盘(如果你登录了,它在https://github.com/) 点击新建存储库 填空;点击创建存储库 按照随后出现的页面上的说明操作
添加一个GitHub存储库作为远程源(将[]替换为您的URL):
git remote add origin [git@github.com:...]
切换到你的主分支并复制它来开发分支:
git checkout master
git checkout -b develop
将你的开发分支推到GitHub的开发分支(-f表示force):
git push -f origin develop:develop
这在优秀的免费电子书ProGit中得到了解释。它假设您已经有一个本地Git存储库和一个远程Git存储库。连接它们使用:
$ git remote
origin
$ git remote add pb git://github.com/paulboone/ticgit.git
$ git remote -v
origin git://github.com/schacon/ticgit.git
pb git://github.com/paulboone/ticgit.git
将数据从本地存储库推送到GitHub使用:
$ git push pb master
如果你还没有设置本地和/或远程存储库,请查看GitHub上的帮助和本书前面的章节。
是的。创建一个新的存储库,在源代码当前存在的目录中执行git init。
更多信息请点击:http://help.github.com/creating-a-repo/
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- 在GitHub上有一个公共回购的私人分支?
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- 只用GitHub动作在特定分支上运行作业
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 是否有一个链接到GitHub下载文件的最新版本的存储库?