使用Github和多台计算机的最佳方式是什么? [英] Whats the best way to work with Github and multiple computers?

查看:92
本文介绍了使用Github和多台计算机的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一些学校评分软件,并决定使用Github来主办这个项目。在我的Ubuntu盒子上构建一些代码后,我将它推送到Github,然后将其克隆到我的MacBook Pro。在编辑MBP上的代码后,我将其推回到Github。第二天早上,我试着用 git pull 来更新Ubuntu盒子上的回购,它给了我各种麻烦。



在这种情况下最好的工作方式是什么?我不想分叉我自己的回购,我真的不想发送自己的电子邮件或拉请求。为什么我不能把Github当作主人并将其推到/拉出到我在不同计算机上的所有个人回购券上?

解决方案

我假设你的问题是当你试图发布 git pull 命令时,你首先创建了repo的机器。



当你克隆现有的git仓库时(就像你在第二台机器MacBook Pro上做的那样),你会自动设置你的 git pull 命令会自动将远程与您的本地修改合并。



但是,当您最初创建一个repo并将其共享到远程存储库时,您必须发出一些命令,让它像自动克隆的repo一样自动化。

 #GitHub为您提供了该指令,您已经完成
#git remote add origin git@github.com:user_name / repo_name.git

#GitHub没有指定以下指令
git config b ranch.master.remote origin
git config branch.master.merge refs / heads / master

这些最后的几条指令配置git,以便将来的 git pull 从该repo中自动合并所有的远程更改。



以下是一些无耻的自我推销。如果你使用Ruby,我已经创建了一个基于Ruby的工具,可以让你用git远程分支来处理所有这些事情。这个工具被称为,不出所料, git_remote_branch : - )



<如果你不使用Ruby,我的工具可能会太麻烦安装。你可以做的是查看我博客上的旧帖子,在这里大部分的东西都可以为你做出明确的表现。鞭打你的git notes文件: - )


I am developing some school grading software and decided to use Github to host the project. After building some code on my Ubuntu box I pushed it to Github and then cloned it down to my MacBook Pro. After editing the code on the MBP I pushed it back to Github. The next morning I tried to update my repo on the Ubuntu box with a git pull and it gave me all kinds of trouble.

Whats the best way to work in this situation? I don't want to fork my own repo and I don't really want to send myself emails or pull requests. Why can't I just treat Github like a master and push/pull from it onto all of my personal repos on different computers?

解决方案

I'll assume your problem was that the machine on which you first created the repo crapped out when you tried to issue the git pull command.

When you clone an existing git repository (like you did on your 2nd machine, the MacBook Pro), you're automatically set up to so your git pull commands will automatically merge the remote with your local changes.

However, when you initially create a repo and then share it on a remote repository, you have to issue a few commands to make things as automated as a on cloned repo.

# GitHub gives you that instruction, you've already done that
# git remote add origin git@github.com:user_name/repo_name.git

# GitHub doesn't specify the following instructions
git config branch.master.remote origin
git config branch.master.merge refs/heads/master

These last few instructions configure git so future git pull's from this repo will merge all remote changes automatically.

The following is a bit of shameless self-promotion. If you use Ruby, I have created a Ruby-based tool that lets you deal with all these kinds of things with git remote branches. The tool is called, unsurprisingly, git_remote_branch :-)

If you don't use Ruby, my tool is probably gonna be too much of a hassle to install. What you can do is look at an old post on my blog, where most of the stuff grb can do for you was explicitly shown. Whip out your git notes file :-)

这篇关于使用Github和多台计算机的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆