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

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

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

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

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


当前回答

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

其他回答

也许你能做的最有用的事情就是阅读在线书籍Pro Git。这是一本相当不错的读物,它为你提供了正确执行事情的概念背景。

我假设你和我一样使用Windows系统,并且安装了Git。您可以在项目目录中通过简单的命令提示符运行这些命令,也可以使用Git Bash。

步骤1:

在Git中手动创建一个存储库。随你怎么称呼它。

步骤2:

进入您的本地项目目录。如果您希望将代码发布到刚刚创建的新存储库中,请确保在项目根目录中没有文件夹名.git。如果有,请删除。 执行命令git init。

步骤3:

运行命令

转到添加 。

步骤4:

运行命令

git commit -m YourCommitName

步骤5:

运行命令

git远程添加YourRepositoryName https://github.com/YourUserName/YourRepositoryName.git

步骤6:

运行命令

git push——set-upstream YourRepositoryName master——force

请注意,我在撰写本文时使用的是最新版本的Git。还要注意,我没有指定要将代码推入的任何特定分支,所以它会进入master。在第6步中,Git会要求您在一个弹出窗口中输入用户名和密码来授权命令。

确保系统上安装了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是你的主分支的名称。如果您有多个分支,请确保选择相应的分支名称。

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

下载Sourcetree。

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

在GitHub上创建一个新的存储库。为避免错误,请不要初始化 包含README、license或gitignore文件的新存储库。你可以 在你的项目被推送到GitHub后再添加这些文件。开放 终端(Mac用户)或命令提示符(Windows和Linux用户) 用户)。 将当前工作目录更改为本地项目。 将本地目录初始化为Git存储库。 git init #在新的本地存储库中添加文件。这将为第一次提交准备它们。

git添加 #在本地存储库中添加文件,并将其提交。要取消文件,使用'git reset HEAD YOUR-FILE'。提交在本地存储库中暂存的文件。

git commit -m '第一次提交' #提交跟踪的更改,并准备将它们推送到远程存储库。要删除这个提交并修改文件,使用'git reset——soft HEAD~1'并再次提交并添加文件。

在GitHub存储库的快速设置页面的顶部,单击复制远程存储库URL。在你的GitHub仓库的快速设置的顶部 页,单击,复制远端存储库URL。 在命令提示符中,添加将在其中推送本地存储库的远程存储库的URL。

$ git远程添加源远程存储库URL #设置新的远程git远程-v 注意:GitHub for Windows用户在这里应该使用命令git remote set-url origin而不是git remote add origin。将本地存储库中的更改推到GitHub。

$ git push origin master #将本地存储库中的更改推到指定为原点的远程存储库。

源代码属性:使用命令行将现有项目添加到GitHub