![](/img/trans.png)
[英]Changing Git protocol for RStudio project already under version control in Windows
[英]Use git to merge sites that aren't already under version control
我们有一个工作中的网站,我们保留两个副本-一个是实时站点,或者是主副本,另一个是测试/暂存站点,在进行较大更改并进行测试之前,此刻将它们手动复制到现场发布。
我们刚刚在该网站上完成了一次检修工作,导致创建或修改了大约40个文件。
我们可以创建两个git分支,每个站点一个,然后使用git生成差异列表并将测试更改合并到实时站点中,即使该站点当前不受版本控制吗?
您可以通过为您的网站初始化git repo轻松地做到这一点。
cd prod_site
git init
git add -A #You may want to ignore some files like libraries for example, use a .gitignore
git commit -m "Initial prod commit"
现在您的产品站点已受版本控制,创建一个分支,然后在其上复制您的暂存网站。
git checkout -b staging
cp -r /path/to/staging/website .
git commit -am "Staging website"
现在您有两个分支:
master
您的产品网站 staging
与暂存网站 现在您可以使用git diff
列出两个分支之间的git diff
git diff master..staging
是的,你可以做到。
您有几种选择:但是为什么不使用超越比较呢?
# cd to the desired folder
# place the content of the first branch in the folder
# init the folder as git repository
git init
# add all the files in the directory and commit them to stash
git add . -A
git commit
# create a new branch for the second content
git checkout -b <b2>
# now copy the second content to this folder
# add the content of the second branch to git
git add . -A
# commit the changes
git commit
简单的方法是在将第二个分支的内容添加到git之前使用git status
在执行此操作之前,请完成上一步:
# now copy the second content to this folder
git add . -A
git commit
# display the differences between the branches
git status
或#显示当前HEAD与等待提交的内容git add之间的差异。 git diff
您可以通过多种方式查看分支罪之间的区别
git log --cc
git log master ^b1
git log ^master b1
gir format-patch HEAD~1
和更多...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.