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

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

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

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

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


当前回答

从Visual Studio Code上传一个项目到GitHub

要使用Visual Studio Code在GitHub中上传项目,请遵循以下步骤。

打开Visual Studio代码。如果你没有VSCode下载:下载Visual Studio Code 在VSCode打开文件>打开文件夹.. 进入终端—>新终端 请依次执行以下命令

git init

转到添加 。

git commit -m“第一次提交”

Git远程添加origin https://github.com/yourusername/your-repo-name.git

Git push origin master

注意:在上面的命令git remote add origin https://github.com/yourusername/your-repo-name.git中,请用你的GitHub帐户名和你的存储库名称更改粗体部分。

其他回答

We need Git Bash In the Git Bash Command Section: ls It will show your default location. CD "C:\Users\user\Desktop\HTML" We need to assign the project path. git init It will initialize the empty Git repository in C:\Users\user\Desktop\HTML ls It will list all file names. git remote add origin https://github.com/repository/test.git It is your https://github.com/repository/test.git is your repository path git remote -v To check whether we have fetch or push permission or not git add . If you use . then it means whatever we have in the particular folder publish all. git commit -m "First time" git push -u origin master

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

确保系统上安装了Git。我正在用windows操作系统解释这个过程[尽管它不应该是依赖于操作系统的工作]

以下是我的做法:

Open the cmd (you can do with git bash as well if you've installed git bash). Go to your project directory (where your project is located, it's essentially changing to directory either usiing cd path or through manual folder navigation). Now type git init. This will initialize an empty repository if it is first time and Enter. For example: git init Now type git add <filename>(if specific file) or git add <filename1> <filename2> <filenameN> (if specific but more than one files) or git add . (if you want to add all files) and enter. Now type git commit -m "commit message goes here" and enter. (in case if you need to check the status you can do by typing git status) and enter. Now type git remote add origin git_repository_url (check git remote -v go check remote repository) and Enter. Now it's turn to push it to the remote repository [essentially taking all the changes from local git to cloud(github) ...git push origin master and enter (if you get error you push it forcefully by typing ...git push -f origin master and enter.

注意:master是你的主分支的名称。如果您有多个分支,请确保选择相应的分支名称。

现在,您已经完成了将它从本地计算机添加到远程存储库的工作。刷新它,它将出现在您创建的存储库的选定分支中。

GitHub发布了一个本地Windows客户端,使以下所有步骤变得多余。

您还可以使用Sourcetree在Windows上获得Git和Mercurial的设置。


下面是你在Windows下的操作方法:

If you don't have Git installed, see this article on how to set it up. Open up a Windows command prompt. Change into the directory where your source code is located in the command prompt. First, create a new repository in this directory git init. This will say "Initialized empty git repository in ....git" (... is the path). Now you need to tell Git about your files by adding them to your repository. Do this with git add filename. If you want to add all your files, you can do git add . Now that you have added your files and made your changes, you need to commit your changes so Git can track them. Type git commit -m "adding files". -m lets you add the commit message in line.

到目前为止,即使你不使用GitHub,上面的步骤也是你要做的。它们是启动Git存储库的正常步骤。请记住,Git是分布式的(去中心化的),这意味着使用Git不需要“中央服务器”(甚至不需要网络连接)。

现在,您希望将更改推到GitHub托管的Git存储库中。你可以通过告诉Git添加一个远程位置来做到这一点,你可以用下面的命令来做到:

Git远程添加origin https://github.com/yourusername/your-repo-name.git

*注意:在你做git远程添加origin之前,你应该在GitHub中创建your-repo-name…

完成此操作后,Git现在就知道远程存储库了。然后你可以让它推送(也就是“上传”)你提交的文件:

Git push -u origin master

尝试使用Git Bash来推送您的代码/进行更改,而不是直接在GitHub上上传文件(它不太容易出错,有时也很舒服-也需要更少的时间!)要做到这一点,你可以遵循以下步骤:

Download and install the latest version of Git Bash from here. Right-click on any desired location on your system. Click “Git Bash Here”. git config --global user.name “your name” git config --global user.email “your email” Go back to your GitHub account – open your project – click on “clone” – copy HTTPS link. git clone PASTE HTTPS LINK. A clone of your GitHub project will be created on your computer location. Open the folder and paste your content. Make sure content is not empty. Right-click inside the cloned folder where you have pasted your content. Click “Git Bash Here” again. You will find (master) appearing after your location address. git add . Try git status to check if all your changes are marked in green. git commit --m “Some message” git push origin master