简体   繁体   English

创建了github页面后,如何修改git工作流程?

[英]How to modify my git workflow now that I created github pages?

I have a local repository on which I work on a daily basis. 我有一个本地存储库,我每天都在该存储库上工作。 Typically, after a day's work, I commit locally and I push everything to a github repo by doing: 通常,在一天的工作之后,我在本地进行提交,然后通过执行以下操作将所有内容推送到github存储库:

git add --all
git status // to check which changes are to be commited 
git commit -m "Some changes I've made"
git push origin master

Recently I've created a github page for my online repository, by clicking away through the online creation tool. 最近,我通过单击在线创建工具为在线存储库创建了一个github页面。 Now I have a beautiful page for my project, and also a new branch (called gh-pages) on my online repo (but --so far-- not on my local repo, of course). 现在,我的项目页面很漂亮,并且在线仓库上还有一个新的分支(称为gh-pages)(但是,到目前为止,当然不在本地仓库上)。

My question is: if I wanted to edit this page locally in my computer and keep both repos synced (the local and the github one), how do I do? 我的问题是:如果我想在计算机上本地编辑此页面,并使两个存储库保持同步(本地和github一个),该怎么办? How should I modify my git workflow? 我应该如何修改git工作流程?

Thanks in advance. 提前致谢。

You just switch back and forth between master , etc. and gh-pages with git checkout . 您只需使用git checkoutmaster等和gh-pages之间来回切换。 More details below. 下面有更多详细信息。

Your original workflow (from above): 您的原始工作流程(来自上方):

git add --all
git status // to check which changes are to be commited 
git commit -m "Some changes I've made"
git push origin master

Now when you want to work on your GH-pages: 现在,当您要在GH页面上工作时:

git fetch origin    # Only needed first time
git checkout gh-pages
# Make changes to your GH-pages files (your master branch files won't be available w/o switching back to master)
git add .    # or specific specific files to add
git commit -m "Commit message for GH-pages"
git push origin gh-pages

When you want to go back to working on the master, develop, etc. branch project, just check it out: 当您想回到主,开发等分支项目上工作时,只需将其签出即可:

git checkout master

This info can sort of be found at the bottom of https://help.github.com/articles/creating-pages-with-the-automatic-generator/ . 该信息可以在https://help.github.com/articles/creating-pages-with-the-automatic-generator/的底部找到。

The process is slightly more complex when the creating gh-pages orphan branch manually: https://help.github.com/articles/creating-project-pages-manually/ 手动创建gh-pages孤儿分支时,此过程稍微复杂一些: https//help.github.com/articles/creating-project-pages-manually/

Of course, if you are not the only one working on the repo or are doing so from multiple computers, be sure to fetch / merge or pull when needed. 当然,如果您不是唯一在仓库上工作的人,或者是从多台计算机上进行工作,请确保在需要时fetch / mergepull fetch

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM