如何重置react应用程序的所有git命令并从新开始



我在推送github时遇到了困难,因为我是新手。我有多个存储库专门用于同一个React应用程序,我一直在放这些看似随机的git命令,这真的很混乱,因为我一直在搞砸。

我以前一直在玩git的东西,但现在我有一个空的github repo,我想推送它。我如何重置之前做的所有事情,并从平方开始,简单地将我的React应用程序推送到github?

在cmd中,我编写了当您第一次创建repo时,Github告诉您的所有非常基本的步骤。这是输出:

C:UserszzzzDocumentsgap>git init 
Reinitialized existing Git repository in C:/Users/zzzz/Documents/gap/.git/
C:UserszzzzDocumentsgap>git add README.md
C:UserszzzzDocumentsgap>git commit -m "first commit"
interactive rebase in progress; onto 2cb97d3
Last command done (1 command done):
pick 9bdce5c first commit
Next command to do (1 remaining command):
pick 705699b Trigger rebuild # empty
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch 'master' on '2cb97d3'.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)       
nothing to commit, working tree clean
C:UserszzzzDocumentsgap>git branch -M master
fatal: Invalid branch name: 'HEAD'
C:UserszzzzDocumentsgap>git remote add origin https://github.com/simonshm5/gap-data-science-covid.git
fatal: remote origin already exists.
C:UserszzzzDocumentsgap>git push -u origin master
Everything up-to-date
Branch 'master' set up to track remote branch 'master' from 'origin'.

我不知道这些错误意味着什么,也不知道如何修复它们。当我运行npm start时,我的程序在localhost上运行得非常好。现在,我只想推送到Github,并将其部署在Github页面上。

您会出现此错误,因为您已经在该文件夹中为此项目初始化了git。因此,首先您必须删除文件夹中的git文件。转到您的项目文件夹并删除名为"的文件夹;。git";。如果看不到该文件夹,请确保打开显示隐藏的文件、文件夹和磁盘。之后,您可以按照以下步骤操作:https://docs.github.com/en/github/importing-your-projects-to-github/importing-source-code-to-github/adding-an-existing-project-to-github-using-the-command-line

最新更新