【问题标题】:Empty folder when pushing from local to remote从本地推送到远程时的空文件夹
【发布时间】:2019-08-23 21:39:33
【问题描述】:

我在VS Code 内部有一个项目,它在本地使用 git,并且所有内容都已提交/最新。

现在我想将所有内容推送到我的服务器,以便在本地工作时更新服务器上的文件。

我已经在我的服务器上设置了我的 git repo 并从 vs code 项目终端连接,但是当我进行推送时,它说一切都是“最新的”,并且服务器上的文件夹是空的,它包含只是.git 文件夹。

我想将我所有的项目文件转移到服务器上的文件夹中,我该怎么做?

现在我在做:

git push origin --all 

我得到Everything is up to date

我也尝试做:

git add.
git commit -m "commit message"

但我明白了

on branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

如何将我所有的本地 git 文件发送到我的服务器 git repo?

【问题讨论】:

  • 请写下 git status 的输出,我也想确认一下 git add。您在 add 和 dot 之间添加空格
  • 另外请确认该命令将打印您的远程 git url, git remote show origin

标签: git visual-studio-code


【解决方案1】:

除了git statusgit remote -v,,别忘了你通常会推送到bare repository

含义:远程目标应该只有一个.git 文件夹,其中包含从本地工作站接收到的压缩文件。

您不会在那里看到任何文件(除了来自 Git 参考的文件)。

【讨论】:

  • 你是对的,我在我的机器上创建了一个新的空项目并在那里克隆了 repo,我得到了所有的文件,所以就像你说的那样,但是我确实想看看使用远程服务器上的文件,如何实现?
  • 知道了,把它克隆到另一个目录,谢谢你帮助我理解。
  • @jukenduit 是的,克隆,或者设置一个接收后挂钩,可以为您进行克隆/更新:stackoverflow.com/a/14453711/6309
【解决方案2】:

让我们从 VSCode 终端尝试一下。

1) 将当前工作目录更改为您的本地存储库(您的 项目目录)。

2) 暂存文件以提交到本地存储库。

git add .
# Adds the file to your local repository and stages it for commit.

3) 提交您在本地存储库中暂存的文件。

git commit -m "Your commit message here"
# Commits the tracked changes and prepares them to be pushed to a remote repository. 

4) 将本地存储库中的更改推送到托管在远程服务器上的存储库(例如:GitHub)。

git push origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin

【讨论】:

    猜你喜欢
    • 2012-12-27
    • 1970-01-01
    • 1970-01-01
    • 2013-06-30
    • 2020-11-27
    • 2021-10-22
    • 2021-06-03
    • 1970-01-01
    • 2014-01-13
    相关资源
    最近更新 更多