简体   繁体   English

我有两个本地存储库,一个在学校一个在家里,另一个在 github 上的远程存储库,我如何从一个本地存储库提交以同步到另一个本地存储库

[英]i have two local repos, one at school one at home, and the remote repo on github, how do i get commits from one local repo to sync to the other local

as stated in the title i have two local repos on two different machines and one github repo synced with both of them remotely, how do i make it so that when i make a change in local repo 1, commit stage and push it to the remote repo, that those changes will update local repo 2 without having to completely remove and reconfig it on the pc.如标题中所述,我在两台不同的机器上有两个本地存储库,一个 github 存储库与它们远程同步,我如何做到这一点,以便当我在本地存储库 1 中进行更改时,提交阶段并将其推送到远程repo,这些更改将更新本地 repo 2,而无需在 PC 上完全删除和重新配置它。 this is probably a noob question but im a noob to github and when i looked into it i tried most of the different commands etc but almost every time i tried any of them i just got the error message 'fatal: not a gir repository (or any of the parent directories): .git.这可能是一个菜鸟问题,但我是 github 的菜鸟,当我查看它时,我尝试了大多数不同的命令等,但几乎每次我尝试其中任何一个时,我都收到错误消息“致命:不是 gir 存储库(或任何父目录):.git。

Your problem is the reason, why there is Git.你的问题是原因,为什么有 Git。 Local repositories (copies) on different computers (at all team-members, or in your case: home and school) and ONE remote repository.不同计算机上的本地存储库(副本)(所有团队成员,或者您的情况:家庭和学校)和一个远程存储库。 In your situation there is no team who works together on one repository, there are only two station (same user), where you have clone the same repository.在您的情况下,没有团队在一个存储库上一起工作,只有两个工作站(同一用户),您可以在其中克隆同一个存储库。 But you must handle this as you work in a team.但是当你在团队中工作时,你必须处理这个问题。

Now if you made changes, you will commit this changes and push it to remote.现在,如果您进行了更改,您将提交此更改并将其推送到远程。 That the other members who works with on this repository (or your other local station (home-school)) become the changes from remote to local, they must pull this changes, that the local repository is up-to-date with the remote.在此存储库(或您的其他本地站(家庭学校))上工作的其他成员成为从远程到本地的更改,他们必须拉取此更改,本地存储库与远程存储库保持同步。 And that you can do with git pull .你可以用git pull做到这一点。

I advise you to do a git tutorial , so that you can handle the most common git commands.我建议你做一个git 教程,这样你就可以处理最常见的 git 命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以将一个本地 git 存储库与两个远程存储库一起使用吗? - Can I use one local git repo with two remote repo? 如何用github上的本地仓库覆盖本地仓库? - How do I overwrite my local repo with the one on github? 两个不同的本地存储库提交到一个 Github 存储库 - Two different local repos commit to one Github repo 将一个本地存储库与远程git存储库同步 - Sync one local repo with the remote git repository 使用git同步两个相同的存储库,一个在本地,另一个在远程主机上(不是github) - using git to sync two identical repos one on local and other on remote host(not github) 一次性将本地 git repo 与远程同步,丢弃本地更改/提交 - Sync local git repo with remote in one shot discarding local changes/commits 如何用远程仓库中的另一个替换本地仓库中的文件? - How to replace a file in local repo with another one from remote repo? 相同的文件,一个大写,另一个不是,出现在远程仓库中,但不是本地仓库 - Identical files, one capitalized and the other not, appearing in remote repo, but not local repo 提交到没有本地Git仓库的远程Git仓库? - Make commits to a remote Git repo without a local one? 我可以在没有本地仓库的情况下使用 gh cli 创建远程 github 仓库吗? - Can I create remote github repo without local one with gh cli?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM