有没有办法可以查看提交到本地 GitHub 分支的更改,而无需将其推送到 master 分支?
我仍在研究 GitHub 和 Heroku,所以请耐心等待。 :)
我在 xyz.com 上有一个网络应用程序。我现在正在做的是对某些文件进行一些代码/UI 更改,提交这些文件,将它们推送到 master 分支,然后刷新 url 以查看这些更改。
我认为这显然是错误的方法,但我不知道如何测试对代码所做的更改,而不必将它们推送到主分支。我怎么能这样做呢?
I'm still figuring GitHub and Heroku out, so please bear with me. :)
I've a web app on, say, xyz.com. What I am doing now is to make some code/UI changes on some files, commit those files, push them to the master branch, and then refreshing the url to see these changes.
I think this is obviously the wrong approach, but I don't know of how else to test changes done to my code without having to push them on to the master branch. How could I do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不太明白您问题的完整版本中的情况(请参阅我的评论,如 icc 询问,为什么不能在本地测试?),但要回答中的问题标题,您可以通过运行以下命令来查看您的 master 版本与 GitHub 上的版本之间的差异:(
假设引用您的 GitHub 存储库的远程版本称为
github
- 它很可能是origin< /code> 在你的情况下,你可以使用 git remote -v 来查看所有遥控器。)
进一步解释一下,当你运行 git fetch github 时,git 会更新所有所谓的“远程跟踪分支” - 在大多数情况下,这些分支看起来像
origin/whatever
、github/experiment
等。这些就像这些分支状态的缓存,只有当您运行git fetch
或成功git Push
到远程存储库上的该分支时,它们才会更新。因此,一旦您完成此操作以确保github/master
是 GitHub 上该分支的最新快照,您就可以愉快地将其与本地master
分支进行比较,使用git diff
。I don't quite understand the situation in the full version of your question (see my comment and, as icc asks, why can't you test locally?), but to answer the question in the title, you can see the differences between your master and the version on GitHub by running:
(That's assuming that the remote that refers to your GitHub repository is called
github
- it might well beorigin
in your case. You can see all your remotes withgit remote -v
.)To explain that a little further, when you run
git fetch github
, git will update all your so-called "remote-tracking branches" - in most cases those are the ones that look likeorigin/whatever
,github/experiment
, etc. Those are like a cache of the state of those branches, and they're only updated when you rungit fetch
or successfullygit push
to that branch on the remote repository. So, once you've done this to make sure thatgithub/master
is a recent snapshot of that branch on GitHub, you can happily compare it with your localmaster
branch usinggit diff
.第一:您不推送到主分支,而是推送到远程存储库。您可能应该阅读您的 git。
第二:这不是一个好的工作流程,首先您应该提交更改,然后在本地测试它们。完成测试后,您就可以将提交推送到远程存储库。
First: You don't push to the master branch, you push to a remote repo. You should probably read up on your git.
Second: This is not a good workflow, first you should commit your changes and then test them locally. When you are done testing you are ready to push your commits to a remote repo.