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


当前回答

添加一个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

其他回答

在git hub中创建存储库

允许通过GIT跟踪您的项目

使用CMD进入项目文件所在的文件夹->cd /automation/xyz/codebase 使用命令git status检查git初始化 如果你得到这个错误消息:fatal: Not a git repository(或任何父目录):.git,这意味着你当前所在的文件夹没有被git跟踪。在这种情况下,在项目文件夹中输入git init初始化git,然后执行添加和提交项目的过程。

如果您收到另一条错误消息,请仔细阅读其中的内容。如果你说“git”这个词不被识别,是不是说git没有安装在你的电脑上?它是否说你已经在git初始化的文件夹或子文件夹中?谷歌你的错误和/或输出来理解它,并找出如何修复它。

现在运行以下命令

#

echo "your git hub repository name" >> README.md git init git添加README.md Git commit -m "第一次提交" Git远程添加原点https:// # 当你第一次打开你的存储库时,你会得到上面的块 如果发生错误或在最后一个命令后没有发生任何事情,运行“git push -u origin master” 不要担心 去文件夹的代码是可用的,并通过git扩展推到git [URL],分支

其中一条评论提到了使用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密钥。

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

正如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存储库作为远程源(将[]替换为您的URL):

git remote add origin [git@github.com:...]

切换到你的主分支并复制它来开发分支:

git checkout master
git checkout -b develop

将你的开发分支推到GitHub的开发分支(-f表示force):

git push -f origin develop:develop