拉取远程存储库
我是一个相当新的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设您已从远程存储库克隆
您已经这样做了,
如果您想从远程主机安全地拉取一点内容,请先执行
,然后
再执行最后检查提交,您可以执行以下操作
Assuming you have cloned from your remote repo
well you already did that with
If you want to pull little safely from your remote host do first
and later
Lastly to check commits you can do
我的一个团队在学习 git 时记住了这 4 个步骤:
git add .
git commit -m 'your message'
git pull 合并冲突?修复它,使代码以相同的方式运行。
git push
这样,只要每个人在推送之前拉取,从技术上讲,不起作用的代码就不应该生效。
希望这有帮助:)
A team of mine when learning git memorized these 4 steps:
git add .
git commit -m 'your message'
git pull
Merge Conflict? Fix it so the code runs the same way.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 :)
如果安全是您的首要任务,那么备份您的工作,并将复制您要使用的存储库到一个新位置,然后继续工作,直到您确定为止你知道自己在做什么。
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)