3

I'm learning Git and implementing it across all my projects. I've successfully installed Git on my local machine, created git repo's for each project, and started pushing all the commits to my bitbucket account for each project.

Now, all of these projects are already live on my production server, where they do not have the corresponding git repo's... yet.

What I'd like to do is be able to pull down commits from bitbucket for each corresponding project so that changes are reflected... and also sets up the git repo on the production server for that project as well.

I hope I explained that right. I'm using SSH and I'm able to git init... also tried git pull and git fetch ... but then when I try to git status after the pull or fetch.... it shows all my files on the production server as untracked. However, they should be already tracked as reflected on my bitbucket repo. Right?

I'm a little confused as to how to do this properly despite hours of reading. Any help or direction pointing would be great!

4

2 回答 2

1

我的假设是您在生产服务器上进行了初始化。

git init

然后添加 bitbucket 作为远程仓库

git remote add bitbucket git://bitbucket.com/project

您应该做的就是在本地提交、获取以及合并或变基。

提交会将您的更改提交到本地存储库,并且不会反映在 bitbucket 上。

git commit -a -m '提交'

fetch 将任何更改从 bitbucket 拉到您的服务器。

git fetch bitbucket 

合并会将任何新更改合并到服务器上的存储库中。

git merge bitbucket/master

但是,在这种情况下,我个人更喜欢 rebase 而不是合并,以便本地更改基本上附加到最后一次提交,而不是与 bitbucket/master 上的提交交织在一起。我发现变基可以减少冲突的数量。

git rebase bitbucket/master

可能会发生合并冲突。在这种情况下,您应该编辑冲突区域,对冲突的文件执行“git add”,然后再次提交它们。

于 2013-02-21T22:00:35.517 回答
0

您可能会错误地配置 SSH。看这里https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git 并尝试做

git remote add origin [链接到你的仓库]

于 2014-02-15T19:22:23.440 回答