我在 C:\ABC 文件夹中有一个本地项目,只是意识到是时候将它备份到 GitHub 了。这就是我所做的:
错误 Git:致命:目标路径“C:\ABC”已经存在并且不是空目录。
我知道它试图从 GitHub 获取到本地,但我想要的是相反的。谷歌搜索了很多关于如何从头开始的文章和视频,但不适用于现有的本地项目。
2021-08 更新,
Von*_*onC 14
尝试使用命令行:
cd c:\ABC
git init .
git config --global user.name <yourGitHubAccount>
git config --global user.email <yourGitHubEmailAccount>
git add .
git status
# edit .gitignore to ignore folder you don't want
git commit -m "first commit"
git remote add origin https://github.com/<yourGitHubAccount>/<yourRepo.git>
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
确保您的 GitHub 存储库实际上是空的(否README.md)
@VonC,重新执行相同的步骤:1)创建一个新的本地空目录,在 VS Code 中将本地空目录链接到 GitHub 上的空存储库,如所述。成功了。
2)用我的代码文件/目录填充这个本地空目录。
3)git init .
系统消息:重新初始化现有的Git存储库.../.git/
3)一次运行这两个命令,没有错误也没有消息。
git config --global user.name Jeb50
git config --global user.email Jeb50@XYZ.com
Run Code Online (Sandbox Code Playgroud)
4)git add .
系统消息:
warning: LF will be replaced by CRLF in .vscode/launch.json.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Angular/Modules/mainApp.js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in content/Site.css.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in package-lock.json.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in package.json.
The file will have its original line endings in your working directory.
Run Code Online (Sandbox Code Playgroud)
5)git status
系统消息:
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .gitignore
new file: .vscode/launch.json
new file: Angular/Controllers/AuthController.js
new file: Angular/Controllers/MainController.js
new file: Angular/Models/user.js
new file: Angular/Modules/mainApp.js
new file: Passport/passport-init.js
new file: Routes/authentication.js
new file: Routes/routerMEAN2.js
new file: Untitled.png
new file: Views/Authentication/login.html
new file: Views/Authentication/register.html
new file: Views/Authentication/unauth.html
new file: Views/Main/About.html
new file: Views/Main/Contact.html
new file: Views/Main/index.html
new file: Views/Starter.ejs
new file: content/Site.css
new file: package-lock.json
new file: package.json
new file: server.js
Run Code Online (Sandbox Code Playgroud)
6)我的.gitignore文件:
# individual files
9222.jpg
err1.jpg
config.js
# exclude folders
node_modules/
Run Code Online (Sandbox Code Playgroud)
7) git commit -m "first commit",看起来没问题,但存储库系统消息下没有显示代码:
[master (root-commit) f8e435e] first commit
21 files changed, 2305 insertions(+)
create mode 100644 .gitignore
create mode 100644 .vscode/launch.json
create mode 100644 Angular/Controllers/AuthController.js
create mode 100644 Angular/Controllers/MainController.js
create mode 100644 Angular/Models/user.js
create mode 100644 Angular/Modules/mainApp.js
create mode 100644 Passport/passport-init.js
create mode 100644 Routes/authentication.js
create mode 100644 Routes/routerMEAN2.js
create mode 100644 Untitled.png
create mode 100644 Views/Authentication/login.html
create mode 100644 Views/Authentication/register.html
create mode 100644 Views/Authentication/unauth.html
create mode 100644 Views/Main/About.html
create mode 100644 Views/Main/Contact.html
create mode 100644 Views/Main/index.html
create mode 100644 Views/Starter.ejs
create mode 100644 content/Site.css
create mode 100644 package-lock.json
create mode 100644 package.json
create mode 100644 server.js
Run Code Online (Sandbox Code Playgroud)
8)git remote add origin https://github.com/Jeb50/MEAN2.git
系统消息:
fatal: remote origin already exists.
Run Code Online (Sandbox Code Playgroud)
9)git push -u origin master
系统消息:
Counting objects: 34, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (29/29), done.
Writing objects: 100% (34/34), 30.77 KiB | 0 bytes/s, done.
Total 34 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/TLKG/MEAN2.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
Run Code Online (Sandbox Code Playgroud)
刷新 GitHub 上的“代码”选项卡,将显示预期的文件。看来工作。
惊人的!
我只需点击三下即可使用 github 桌面应用程序来完成此操作: https://help.github.com/en/desktop/contributing-to-projects/adding-a-repository-from-your-local-computer-to -github-桌面
关键方向是这样的:您可以将任何 Git 存储库添加到 GitHub Desktop,即使它不是 GitHub 存储库。
单击创建存储库后,您将看到以下内容:
最后,它甚至会提示你将其发布到 Github 进行备份:
| 归档时间: |
|
| 查看次数: |
15984 次 |
| 最近记录: |