jam*_*z77 178 upload github repository git-gui git-bash
检查完这个问题后,我仍然不知道如何将项目上传到我的Git Hub存储库.
我是Git Hub的新手,我不知道该怎么做.我创建了一个存储库,但我想将我的项目上传到它.
我在存储库页面上查看了某种上传按钮,但我还没有看到任何类似的东西.
我看过目前为止提供的链接,但我仍然没有在哪里.他们提到命令行,是Windows命令行还是Git Bash?因为我无法做任何事情.
我也尝试过使用Git GUI,但是当我选择我想要的文件夹时,它说它不是Git存储库...是否需要压缩?我尝试在文件夹中添加.gitconfig文件,但它没有什么区别.
提前致谢 :)
Bur*_*lid 247
自从我写这个答案以来,github发布了一个原生的Windows客户端,它使以下所有步骤都变得多余.
您还可以使用sourcetree在Windows上同时获取git和mercurial设置.
以下是在Windows中执行此操作的方法:
git init
.这将说".... git中初始化的空git存储库"(...
是路径).git add filename
.如果要添加所有文件,可以执行此操作git add .
git commit -m "adding files"
.-m
允许您添加提交消息.到目前为止,即使您没有使用github,上述步骤也是您要做的.它们是启动git存储库的常规步骤.请记住,git是分布式的(分散的),意味着您不需要拥有"中央服务器"(甚至是网络连接)来使用git.
现在,您希望将更改推送到使用github托管的git存储库.通过告诉git 添加远程位置,您可以使用此命令执行此操作:
git remote add origin https://github.com/yourusername/your-repo-name.git
完成后,git现在知道您的远程存储库.然后,您可以告诉它推送(即"上传")您提交的文件:
your-repo-name
Ris*_*hak 56
按照以下步骤投影到Github
1) git init
2) git add .
3) git commit -m "Add all my files"
4) git remote add origin https://github.com/yourusername/your-repo-name.git
从头开始上传项目需要
git pull origin master
.
5) git pull origin master
6) git push origin master
小智 18
git push --force origin master
Run Code Online (Sandbox Code Playgroud)
如果你上传有问题!
小智 16
易于遵循的步骤:git pull origin master
否则main
会给出致命错误:
找不到远程参考主
所以下面的步骤就可以正常工作。
git init
git add .
git commit -m "initial commit"
git remote add origin https://github.com/yourusername/your-repo-name.git
git branch -M main
git push -u origin main
小智 14
请遵循以下两个步骤:
git add remote origin https://github.com/userName/repo.git
将本地仓库链接到远程仓库:这里repo.git将是您新创建的远程仓库.这将像一个魅力.无需担心SSH或HTTPS方式.我首先遇到了同样的问题,花了几个小时来解决问题.但这对我有用.
Ale*_*lex 11
在这里我解释我是如何在Window上做的,也许它也有助于其他人:)
安装完成后,打开"git bash";
所以会弹出如下窗口:
来吧,输入cd ~
以确保您在主目录;
您可以通过键入来检查您所在的地址pwd
;
现在您需要创建一个GitHub帐户;
创建GitHub帐户后,请继续并登录;
登录后,在右上角单击+并选择"新存储库"
然后在打开的窗口中,在"存储库名称"框中键入您希望存储库的名称.如果愿意,添加"描述(可选)",并标记"使用自述文件初始化此存储库".然后单击"创建存储库".
现在去找你的C驱动程序; 创建一个新文件夹并将其命名为"git"现在转到"git bash"窗口; 通过键入将目录更改为c驱动器cd ~; cd /c
如果您ls
在那里键入它将显示那里的文件夹; 确保它显示git文件夹:
现在回到浏览器; 转到您的GitHub页面,单击您创建的存储库; 并单击"克隆或下载"; 并复制显示那里的地址(通过选择复制到剪贴板)
现在回到"git bash"; 使用该命令cd git
转到git文件夹; 现在编写以下命令连接到您的GitHub(当它询问您时输入您的GitHub的用户名和密码)
git config --global user.name "Your Name"
Run Code Online (Sandbox Code Playgroud)
然后:git config --global user.email youremail@domain.com
.下一个类型:git clone (url)
,而不是(url),键入从GitHub页面复制的GitHub存储库的地址; (例如git clone https://github.com/isalirezag/Test.git).
现在,如果您执行ls
命令,您将在那里看到您的存储库; 如果您还打开了窗口中的git文件夹,您将看到您的存储库已添加为文件夹.
现在使用cd命令转到存储库: cd Test
继续,将要放入此存储库的任何文件复制并粘贴到该文件夹中.
要将文件传输到存储库,您需要立即执行以下操作:
输入git
add filename
(filename是您要上传的文件名),或者如果要添加文件夹中的所有文件,可以键入以下命令:
git add .
然后键入:git commit -m "adding files"
.然后:git push -u origin master
.
然后你应该全部设置,如果你刷新你的GitHub帐户文件应该在那里:)
这对我有用;
1- git init
2- git add .
3- git commit -m "Add all my files"
4- git remote add origin https://github.com/USER_NAME/FOLDER_NAME
5- git pull origin master --allow-unrelated-histories
6- git push origin master
Run Code Online (Sandbox Code Playgroud)
请按照以下步骤将您的项目上传到Github
1) git init
2) git add .
3) git commit -m "Add all my files"
4) git remote add origin https://github.com/yourusername/your-repo-name.git
从头开始上传项目需要git pull origin master。
5) git pull origin master
6) git push origin master
如果在使用中出现任何问题 git push --force origin master
在GitHub上创建一个新的存储库.为避免错误,请不要使用README,license或gitignore文件初始化新存储库.将项目推送到GitHub后,可以添加这些文件.打开终端(适用于Mac用户)或命令提示符(适用于Windows和Linux用户).
将当前工作目录更改为本地项目.
将本地目录初始化为Git存储库.
git init
#Add the files in your new local repository. This stages them for the first commit.
git add
# Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'. Commit the files that you've staged in your local repository.
git commit -m 'First commit'
#Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
- 在GitHub存储库的快速设置页面的顶部,单击
复制远程存储库URL.在GitHub存储库的"快速设置"页面的顶部,单击以复制远程存储库URL.
- 在命令提示符下,添加将推送本地存储库的远程存储库的URL.
$ git remote add origin remote repository URL
# Sets the new remote git remote -v
# Verifies the new remote URL Note: GitHub for Windows users should use the command git remote set-url origin instead of git remote add origin here. Push the changes in your local repository to GitHub.
$ git push origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin.
来源归因:https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
$ git init
$ git add .
$ git commit -m "First commit"
$ git remote add origin remote repository URL
$ git push origin master
我假设您在像我这样的Windows系统上,并且已安装GIT。您可以通过项目目录中的简单命令提示符运行这些命令,也可以使用GitBash。
步骤1:在GIT中手动创建存储库。给它任何您认为合适的名称。
步骤2:进入本地项目目录。如果要将代码发布到刚刚创建的新存储库中,请确保在项目根目录中没有文件夹名称.git(如果有的话)将其删除。运行命令git init
步骤3:执行命令
git add .
步骤4:运行命令
git commit -m YourCommitName
步骤5:运行命令
git remote add YourRepositoryName https://github.com/YourUserName/YourRepositoryName.git
步骤6:运行命令
git push --set-upstream YourRepositoryName master --force
请注意,在撰写本文时,我正在使用最新版本的GIT。还要注意,我没有指定任何特定分支将代码推送到其中,因此它进入了master。在第6步中,GIT将要求您在弹出窗口中输入用户名和密码来授权命令。
希望我的回答有所帮助。
首先你必须在 GitHub 上创建一个帐户
然后创建一个新项目 - 根据需要命名该项目,然后显示您的项目 URL
现在复制网址
然后打开命令提示符并使用cmd转到要上传的目录或文件夹
然后输入以下命令
git init
git add .
git commit -m "initial commit"
git remote add origin PASTE URL
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
现在检查您的 GitHub 帐户。存储库已成功上传。
如需完整指导,您可以观看此视频。