将现有项目推入Github [英] Push existing project into Github

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

问题描述

我的项目资源有一个文件夹。我如何将这个项目推入Github的仓库?

I have a folder with my project sources. How I can push this project into Github's repository?

我试过使用这个步骤:

I tried using this steps:


  1. 我在GitHub上创建了空的存储库。

  2. 我运行git-bash并键入 git init ,所以在project root里面出现 .git 文件夹。

  3. 我使用添加了一些文件到版本控制> git add sourcesFolderName

  4. 在上一步中使用 git commit -m初始提交

  5. 我使用指定远程存储库> git remote add MyProject< url>

  6. 最后 git push ,但没有任何内容被推送到远程回购... (无授权失败)
  1. I created empty repository on GitHub.
  2. I run git-bash and typed git init, so inside project root appeared .git folder.
  3. I added some files to version control using git add sourcesFolderName
  4. I committed files added in previous step using git commit -m "initial commit"
  5. I specified remote repository using git remote add MyProject <url>
  6. Finally git push, but nothing is pushed to remote repo... (no authorization failure)

那么我怎样才能将现有资源推入新创建的github回购?

So how I can push existing sources into newly created github repo?

推荐答案

git init
git add .
git commit -m "Initial commit"
git remote add origin <project url>
git push -f origin master

-f git push 上的code>选项强制推送。如果你不使用它,你会看到这样的错误:

The -f option on git push forces the push. If you don't use it, you'll see an error like this:

To git@github.com:roseperrone/project.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:roseperrone/project.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

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

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