拉取远程存储库

发布于 2024-12-08 13:25:23 字数 318 浏览 2 评论 0原文

我是一个相当新的 Git 用户,只熟悉基本命令。我已将 Git 存储库克隆到本地分支,然后使用:

git add file.txt
git commit -m 'my message'
git push

到目前为止,这可以正常提交。现在,我被要求将我的更改拉入远程存储库。由于这是我第一次执行此操作,因此我希望“安全”地执行此操作,而不会对远程存储库进行任何无意的更改。我还想在拉取之前检查提交,这样我确信我拉入了正确的内容。

因此,我将通过 SSH 连接到远程服务器并提取我在本地存储库中所做的更改。

最好的方法是什么?

I'm a fairly new Git user who's only familiar with basic commands. I've cloned a Git repository to a local branch, then used:

git add file.txt
git commit -m 'my message'
git push

So far, this is working fine to commit. Now, I've been asked to pull my changes into the remote repository. Since this is the first time I've ever done this, I want to do so 'safely,' without making any inadvertent changes to the remote repo. I'd also like to review the commits before pulling them so I'm sure I'm pulling in the right ones.

So, I'll be SSHing into the remote server and pulling the changes I've made in my local repository.

What is the best way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

想念有你 2024-12-15 13:25:23

。我已将 Git 存储库克隆到本地

假设您已从远程存储库克隆

现在,我被要求将我的更改拉入远程存储库

您已经这样做了,

git push

如果您想从远程主机安全地拉取一点内容,请先执行

git fetch

,然后

git merge origin/master

再执行最后检查提交,您可以执行以下操作

git log

. I've cloned a Git repository to a local

Assuming you have cloned from your remote repo

Now, I've been asked to pull my changes into the remote repository

well you already did that with

git push

If you want to pull little safely from your remote host do first

git fetch

and later

git merge origin/master

Lastly to check commits you can do

git log
︶ ̄淡然 2024-12-15 13:25:23

我的一个团队在学习 git 时记住了这 4 个步骤:

  1. ADD ~ git add .
  2. COMMIT ~ git commit -m 'your message'
  3. PULL ~ git pull 合并冲突?修复它,使代码以相同的方式运行。
  4. PUSH ~ git push

这样,只要每个人在推送之前拉取,从技术上讲,不起作用的代码就不应该生效。

希望这有帮助:)

A team of mine when learning git memorized these 4 steps:

  1. ADD ~ git add .
  2. COMMIT ~ git commit -m 'your message'
  3. PULL ~ git pull Merge Conflict? Fix it so the code runs the same way.
  4. PUSH ~ git push

This way, as long as everyone pulls before they push, technically code that doesn't work should never make it live.

Hope this helps :)

枕梦 2024-12-15 13:25:23

如果安全是您的首要任务,那么备份您的工作,并将复制您要使用的存储库到一个新位置,然后继续工作,直到您确定为止你知道自己在做什么

RTFM

查看 git help pull (直到 < a href="http://www.kernel.org/pub/software/scm/git/docs/git-pull.html" rel="nofollow noreferrer">此 恢复)

If safety is your priority, then backup your work and copy the repository you're going to work on, to a new place, and work on that until you're sure you know what you're doing.

RTFM

check out git help pull (until this gets back up)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文