Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将现有项目推入Github_Git_Github - Fatal编程技术网

将现有项目推入Github

将现有项目推入Github,git,github,Git,Github,我有一个包含项目源的文件夹。如何将此项目推送到Github的存储库中 我尝试使用以下步骤: 我在GitHub上创建了空存储库 我运行gitbash并键入gitinit,因此在项目根目录中出现了.git文件夹 我使用git add sourcesFolderName向版本控制添加了一些文件 我使用git commit-m“initial commit” 我使用git remote add MyProject指定了远程存储库 最后,git-push,但没有任何内容被推送到远程repo。。。(无授权失

我有一个包含项目源的文件夹。如何将此项目推送到Github的存储库中

我尝试使用以下步骤:

  • 我在GitHub上创建了空存储库
  • 我运行gitbash并键入
    gitinit
    ,因此在项目根目录中出现了
    .git
    文件夹
  • 我使用git add sourcesFolderName向版本控制添加了一些文件
  • 我使用
    git commit-m“initial commit”
  • 我使用git remote add MyProject指定了远程存储库
  • 最后,
    git-push
    ,但没有任何内容被推送到远程repo。。。(无授权失败)

  • 那么,我如何将现有资源推送到新创建的github repo中呢

    按下时,您需要指定哪个分支哪个遥控器

    ➤ git init ./
    ➤ git add Readme.md
    ➤ git commit -m "Initial Commit"
    ➤ git remote add github <project url>
    ➤ git push github master
    
    这将允许您从master执行
    git推送
    ,而无需指定远程或分支。

    如果您在Mac上(这可能在PC上也适用),下面是一个非常简单的方法。奇怪的是,我到处寻找这个简单的过程,却从未找到它

    • 不要在Github上做任何事情(除了拥有一个帐户,并且没有用完所有可用的回购)
    • 下载GitHub for Mac并安装。检查帐户设置等。不要为现有项目创建任何存储库
    • 在存储库中“添加新的本地存储库”
    • 选择现有文件夹。它会问你是否想这样做,说是的
    • 完成后,您将看到所有文件的列表,等等。提交它们
    • 转到存储库并发布(如果您正确设置了帐户,这将在GitHub上为您创建新的repo)
    • 转到存储库并推送(您将看到“无需推送”的内容,或者它将您的文件/更改推送到新的自动生成的repo)。
      • 想知道为什么你在其他地方找不到这个简单的过程

    我知道不建议将项目文件夹用作回购文件夹。我一直这样做,它总是有效的,它使它变得简单,我从来没有任何问题

    我将遵循Rose p之前的评论。我花了很长时间才找到解决方案,所以我正在转载(希望用简单的英语)对我有用的东西

    git init
    git add .
    git commit -m "Initial commit"
    git remote add origin <project url>
    git push -f origin master
    
    步骤1:在Github.com上创建新的存储库(如果已经有存储库,请跳过)

    步骤2:关闭XCode…不需要

    步骤3:打开一个新的终端窗口(是的,你必须使用终端…我尝试了所有其他方法…没有任何效果)

    步骤4:使用命令cd查找项目(要添加到现有或新存储库的项目)的文件夹位置

    步骤5:键入git init 你会得到这样的东西。重新初始化/{current directory}中的现有Git存储库

    步骤6:键入git add。 此步骤后不会发生任何事情,但请键入它并继续执行下一步

    步骤7:键入git commit-m“Initial commit” 您将获得以下内容:#在分支上,无需提交任何内容,工作目录已清理

    对配置进行一些解释,然后列出已更改的文件列表

    步骤8:键入git remote add origin{project url} 可以在Github.com中找到项目url。它是HTTPS克隆URL…您应该能够复制并粘贴到终端窗口。如果系统告诉您原点已存在,请创建其他名称或使用项目名称(其他名称)

    步骤9:转到mac上的GitHub应用程序并单击“同步分支”按钮(即使没有挂起的更改)。我认为它需要一段时间才能真正提交,但如果您返回到本地存储库文件夹,您应该会看到您的新项目。我不得不重新创建父文件夹,但这只是移动文件的问题。转到GitHub.com并刷新浏览器,您的新文件也应该在那里

    我希望这有帮助

    用不太专业的术语来说 我的回答没有什么不同,但我正在添加更多的信息,因为那些新的信息可以从填补信息空白中获益

    在github上创建repo后,他们会给出说明。你可以跟着这些。但这里有一些额外的提示,因为我知道开始使用git是多么令人沮丧

    假设您已经在本地启动了项目。你有多少并不重要。但是让我们假设您有一个php项目。假设您有index.php、contact.php和一个包含图像、css和字体的资产文件夹。您可以这样做(简单),但有很多选择:

    选择1 登录您的github帐户并创建回购协议

    在下面的屏幕中,如果单击按钮(屏幕右侧)以“在桌面中克隆”,您可以将其复制到需要的位置

    然后,您可以(或以另一种方式)将现有项目中的内容复制到新的回购协议中。使用github应用程序,您可以使用他们的GUI从那里提交(这意味着您只需单击应用程序中的按钮)。当然,您需要为提交输入注释

    选择2
    • 如上所述,在github上创建您的回购协议
    • 在您的计算机上,使用终端转到您的目录。使用linux命令行,您可以cd进入目录。从这里运行以下命令,将现有项目“连接”到github上的repo。(这是假设您在github上创建了回购协议,但它当前为空)
    首先执行此操作以初始化git(版本控制)

    然后执行此操作以添加所有要“监视”的文件。如果有要忽略的文件,则需要添加一个
    .gitignore
    ,但为了简单起见,请使用此示例进行学习

    git add .
    
    然后提交并在
    之间添加注释,如“首次提交”等

    现在
    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.
    
    git init
    
    git add .
    
     git commit -m "Initial Commit"
    
    git remote add github <project url>
    
    git remote add github https://github.com/JGallardo/urbanhistorical.git
    
    git remote -v
    
    git push github master
    
    git push origin master
    
    git push -f origin master
    
    git init
    
    git add .
    
    git commit -m "First commit"
    # Commits the tracked changes and prepares them to be pushed to a remote
    
    git remote add origin remote repository URL
    # Sets the new remote
    git remote -v
    # Verifies the new remote URL
    
    git push origin master
    # Pushes the changes in your local repository up to the remote repository you 
    
    Follow below gitbash commands to push the folder files on github repository :-
    1.) $ git init
    2.) $ git cd D:\FileFolderName
    3.) $ git status
    4.) If needed to switch the git branch, use this command : 
        $ git checkout -b DesiredBranch
    5.) $ git add .
    6.) $ git commit -m "added a new folder"
    7.) $ git push -f https://github.com/username/MyTestApp.git TestBranch
        (i.e git push origin branch)
    
    1)git init
    2)git add *
    3)git commit -m "first commit"
    4)git remote add origin https://github.com/yuvraj777/GDriveDemo.git
    5)git push -u origin master
    
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'git@github.com:<my repo>.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 integrate the remote changes
    hint: (e.g., 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    
    git remote add origin <github repo url>
    cp README.md README.md-save
    git pull origin master --allow-unrelated-histories
    mv README.md-save README.md
    git commit -a
    git push
    
    git init
    git status
    git add "*"
    git commit -m "Comment you want"
    git remote add origin  https://link
    git push  -u origin master
    
    git clone <url>
    cd "repositoryName"
    touch README.md
    git add README.md
    git commit -m "add README"
    git push -u origin master
    
    cd existing_folder
    git init
    git remote add origin <url>
    git add .
    git commit -m "Initial commit"
    git push -u origin master
    
    cd existing_repo
    git remote rename origin old-origin
    git remote add origin <url>
    git push -u origin --all
    git push -u origin --tags
    
    git add .
    git commit -m "v2"
    git push origin master
    
    git init
    git add README.md
    git commit -m "first commit"
    git remote add origin https://github.com/user/repo.git
    git push -u origin master
    
    git remote add origin https://github.com/user/repo.git
    git push -u origin master
    
    git remote add origin https://github.com/<your-github-username>/new-repository.git
    
    # Go into your existing directory and run below commands
    cd docker-spring-boot
    echo "# docker-spring-boot" >> README.md
    git init
    git add -A
    git commit -m "first commit"
    git branch -M master
    git remote add origin https://github.com/devopsmaster/docker-spring-boot.git
    git push -u origin master