Git pull不拉取所有内容

xtfmy6hx  于 2023-08-01  发布在  Git
关注(0)|答案(3)|浏览(213)

我有一个服务器,那里有一些我不知道的配置,我只是git pull,它得到了github repo中的内容,然后重新启动它以便部署。
问题是,有一个提交不是我的最新提交,也不是我的服务器上。文件不在. gitignore中。我如何保证一个拉,拉一个提交?
我真的不知道该怎么修复,我在考虑重启一切:(

14:41][root@someserver] someserver_dir (master)$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   Gemfile
#   modified:   Gemfile.lock
#   modified:   config/assets.yml
#   modified:   config/database.yml
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   randomfiles

字符串

7y4bm7vi

7y4bm7vi1#

如果你总是希望你的服务器版本反映你的仓库中的一个提交,使用git reset而不是git pull可能更好--这样你就不会调用合并功能,而是将所有的文件设置为你重置的提交中的文件。举例来说:

git fetch origin master
git reset --hard FETCH_HEAD

字符串

i5desfxk

i5desfxk2#

可以使用git pull origin branch_name
例如:如果我在GitHub上有一个生产分支,那么我会写git pull origin production,它会给予我所有最新的提交。
只执行git pull有时并不能给予你生产分支的最新提交,即使你正在那个分支上工作并提交它。
幕后工作
http://git-scm.com/docs/git-pull#_default_behaviour
Explanation and Examples

x33g5p2x

x33g5p2x3#

尝试清理本地仓库,然后运行git pull:

$ git gc --prune=now
$ git remote prune origin

字符串

相关问题