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


当前回答

实际上,如果你选择在GitHub上创建一个空的repo,它会给你确切的指令,你几乎可以复制和粘贴到你的终端(在这个时间点):

…or create a new repository on the command line

echo "# ..." >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:<user>/<repo>.git
git push -u origin master

其他回答

是的。创建一个新的存储库,在源代码当前存在的目录中执行git init。

更多信息请点击:http://help.github.com/creating-a-repo/

这在优秀的免费电子书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上的帮助和本书前面的章节。

当我尝试做皮特的步骤时,我在合并方面遇到了一些麻烦。这些是我最后的步骤。

Use your OS to delete the .git folder inside of the project folder that you want to commit. This will give you a clean slate to work with. This is also a good time to make a .gitignore file inside the project folder. This can be a copy of the .gitignore created when you created the repository on github.com. Doing this copy will avoid deleting it when you update the github.com repository. Open Git Bash and navigate to the folder you just deleted the .git folder from. Run git init. This sets up a local repository in the folder you're in. Run git remote add [alias] https://github.com/[gitUserName]/[RepoName].git. [alias] can be anything you want. The [alias] is meant to tie to the local repository, so the machine name works well for an [alias]. The URL can be found on github.com, along the top ensure that the HTTP button out of HTTP|SSH|Git Read-Only is clicked. The git:// URL didn't work for me. Run git pull [alias] master. This will update your local repository and avoid some merging conflicts. Run git add . Run git commit -m 'first code commit' Run git push [alias] master

从Bitbucket都:

向上推一个现有的存储库。您的计算机上已经有了Git存储库。让我们把它推到Bitbucket:

cd /path/to/my/repo
git remote add origin ssh://git@bitbucket.org/javacat/geo.git
git push -u origin --all   # To push up the repo for the first time

打开你的GitHub仪表盘(如果你登录了,它在https://github.com/) 点击新建存储库 填空;点击创建存储库 按照随后出现的页面上的说明操作