简体   繁体   English

将所有内容拉到git中的特定提交

[英]Pulling everything till a specific commit in git

I've two servers - Staging and Live. 我有两台服务器-Staging和Live。 I keep my staging server up-to-date so it has all the latest changes push to my git repo. 我将登台服务器保持最新状态,以便将所有最新更改推送到我的git repo。 Now I want to update my Live server but I don't want to pull everything from my repo but only till a specific commit. 现在我想更新我的Live服务器,但是我不想从回购中提取所有内容,而只能提取特定的提交内容。

When I do 当我做

git status

it says 它说

# git status
# On branch master
# Your branch is ahead of 'origin/master' by 21 commits.
#

When I do 当我做

git checkout 7c7f78382fgh9e642d9b3298acacc5903410fefa

I get an error... 我得到一个错误...

fatal: reference is not a tree: 7c7f78382fgh9e642d9b3298acacc5903410fefa

Any idea what can be wrong. 任何想法可能是错的。

Do I need to pull everything latest and then do checkout ? 我需要把所有东西都拉到最新然后结帐吗?

Thanks! 谢谢!

You need to fetch the remote commits before you can use them. 您需要先获取远程提交,然后才能使用它们。

On your production server: 在生产服务器上:

git fetch origin                                      # Fetches commits from the remote repository
git checkout 7c7f78382fgh9e642d9b3298acacc5903410fefa # Moves forward to the relevant one

To be clearer, you should actually check out a hash to a branch, otherwise you'll be in a detached head state. 更清楚地说,您实际上应该签出到分支的哈希,否则您将处于分离状态。

git fetch origin                        # Fetches commits from the remote repository
git checkout -b new_branch_name 7c7f783 # creates a new branch from this commit.

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

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