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


当前回答

正如JB非常正确地指出的那样,在GitHub上,只要简单地按照说明进行操作就变得非常容易。

下面是登录时使用http://github.com/new在GitHub上设置新存储库后显示的说明示例。

Global setup:

 Set up Git:
  git config --global user.name "Name"
  git config --global user.email email@gmail.com


Next steps:

  mkdir audioscripts
  cd audioscripts
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin git@github.com:ktec/audioscripts.git
  git push -u origin master


Existing Git repository?

  cd existing_git_repo
  git remote add origin git@github.com:ktec/audioscripts.git
  git push -u origin master


Importing a Subversion repository?

  Check out the guide for step-by-step instructions.

再简单不过了!!

其他回答

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

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

正如JB非常正确地指出的那样,在GitHub上,只要简单地按照说明进行操作就变得非常容易。

下面是登录时使用http://github.com/new在GitHub上设置新存储库后显示的说明示例。

Global setup:

 Set up Git:
  git config --global user.name "Name"
  git config --global user.email email@gmail.com


Next steps:

  mkdir audioscripts
  cd audioscripts
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin git@github.com:ktec/audioscripts.git
  git push -u origin master


Existing Git repository?

  cd existing_git_repo
  git remote add origin git@github.com:ktec/audioscripts.git
  git push -u origin master


Importing a Subversion repository?

  Check out the guide for step-by-step instructions.

再简单不过了!!

实际上,如果你选择在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存储库,而不“克隆”远程,执行以下操作(我经常这样做-你在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

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

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