检查后,我如何上传我的项目的Git存储库到GitHub?,我仍然不知道如何让一个项目上传到我的GitHub存储库。

我创建了一个存储库,并想将我的项目上传到它。

我在存储库页面上查看了某种上传按钮,但我没有看到任何类似的东西。

到目前为止,我已经查看了提供的链接,但仍然一无所获。他们提到了命令行;是Windows命令行还是Git Bash?因为我不能让他们做任何事。

我也尝试使用Git GUI,但是当我选择我想要的文件夹时,它说它不是Git存储库…需要拉上拉链吗?我尝试在文件夹中添加.gitconfig文件,但没有什么不同。


当前回答

简单的步骤:git拉源master或main会给出一个致命错误:

无法找到远程参考主机

下面的步骤就可以了。

git init Git添加。 Git commit -m "初始提交" Git远程添加origin https://github.com/yourusername/your-repo-name.git git分支-M main Git push -u origin main

其他回答

我认为最简单的方法就是为Eclipse安装Git插件。它的工作原理或多或少与Eclipse CVS和SVN插件相同。

为了将一个新项目上传到Git中(首先你需要有项目的本地代码库和上传项目的Git存储库。在Git中,你需要有你的凭证)。

List item Open Git Bash Go to the directory where you have the code base (project location) cd to project location cd ////** Then here you need to execute Git commands. git init Press Enter then you will see something like this below. The initialized empty Git repository in ://****/***/.git/, so git init will initialize the empty Git repository at local git add . Press Enter The above command will add all the directories, subdirectories, files, etc. You will see something like this: warning: LF will be replaced by CRLF in **************. The file will have its original line endings in your working directory. git commit -m "first commit" Press Enter. -m provided option for adding comment. It will commit the code to the stage environment. You will see some thing like this: [master (root-commit) 34a28f6] adding ******** warning: LF will be replaced by CRLF in c*******. The file will have its original line endings in your working directory. 27 files changed, 3724 insertions(+) create mode 100644 ***** create mode 100644 ***** create mode 100644 ***** git remote add origin http://username@git:repopath.git Press Enter. This will add to the repository. git push -u origin master Press Enter. This will upload all from local to repository in this step you need to enter password for the repository where you will be uploading the code. You will see some thing like this below: Counting objects: 33, done. Delta compression using up to 12 threads. Compressing objects: 100% (32/32), done. Writing objects: 100% (33/33), 20.10 KiB | 0 bytes/s, done. Total 33 (delta 14), reused 0 (delta 0) To http://username@git:repolocation.git \ [new branch] master -> master Branch master set up to track remote branch master from origin.

上传项目到Git的步骤:

步骤1 -打开cmd并将当前工作目录更改为您的项目位置。

步骤2 -将项目目录初始化为Git存储库。

git init

步骤3 -在本地存储库中添加文件。

add .

步骤4 -提交您在本地存储库中暂存的文件。

git commit -m "First commit"

步骤5 -复制远程存储库URL。

步骤6 -在本地位置中添加远程存储库URL作为源。

git add origin copied_remote_repository_url

步骤7 -确认您的来源是否更新。

git remote show origin

第8步-推更改到您的GitHub存储库

git push origin master.

下载Sourcetree。

它适用于Windows 7(及更高版本)和Mac,强烈建议通过交互式UI在GitHub上上传文件。

Open Git Bash. Change the current working directory to your local project. Initialize the local directory as a Git repository: $ git init Add the files in your new local repository. This stages them for the first commit: $ git add . Commit the files that you've staged in your local repository: $ git commit -m "First commit" At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL. In the Command prompt, add the URL for the remote repository where your local repository will be pushed : $ git remote add origin remote repository URL Push the changes in your local repository to GitHub: $ git push origin master