我在我的笔记本电脑上做了一个 repo 。它在 github.com 上有一个项目页面。
我现在在台式电脑上工作。我手动复制了一些文件,因为我认为我不需要存储库中的每个文件(所以我没有将存储库克隆到我的桌面上)。如何将我的桌面本地文件夹与现有的存储库连接,以便我可以将桌面上的文件推送到存储库(桌面文件现在是这些文件的最新版本,因为我停止在笔记本电脑上工作)
最佳答案
使用命令行将现有项目添加到 GitHub:
# Initialize the local directory as a Git repository.
git init
# Add files
git add .
# Commit your changes
git commit -m "First commit"
# Add remote origin
git remote add origin <Remote repository URL>
# <Remote repository URL> looks like: https://github.com/user/repo.git
# Verifies the new remote URL
git remote -v
# Push your changes
git push origin master
@evolutionxbox 建议您采用第二种方式:
- 克隆 git 仓库
- 复制粘贴进去
- 在原点推送您的更改
如果在任何情况下 git 拒绝您的推送,您可以使用 git push origin master --force
更新(2020 年 10 月 23 日): 请记住,自 2020 年 10 月 1 日起,Github 将默认存储库从 master 重命名为 main https://github.com/github/renaming
关于git - 如何将本地文件夹连接到现有的 github 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50025872/