thiagofm
thiagofm

Reputation: 5883

Git pull not pulling everything

I have a server where there's some config that I don't properly know where i just git pull and it gets what is in a github repo, then restart it in order to deploy.

The thing is, there's a commit which isn't my latest, that isn't really on my server. The files aren't in .gitignore. How do I assure that a pull, pulled a commit?

I really don't know how to fix it, I'm thinking about restarting everything :(

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

Upvotes: 77

Views: 217423

Answers (5)

Rajib Bin Alam
Rajib Bin Alam

Reputation: 389

git fetch origin master
git reset --hard FETCH_HEAD

From the first comment.

Upvotes: -1

Aminah Nuraini
Aminah Nuraini

Reputation: 19146

Check if your branch is tracking the right latest commit. Check it using git branch -avv

If it really does not track the right commit, hard reset the FETCH_HEAD using git reset --hard [commit hash]

Upvotes: 2

invinciblemuffi
invinciblemuffi

Reputation: 1145

You can use git pull origin branch_name.

Ex: If I have a production branch on GitHub, then I will write git pull origin production which will give me all the latest commits.

Only doing git pull sometimes does not give you the latest commits of production branch even though you are working on that branch and committing it.

Behind the scenes working

http://git-scm.com/docs/git-pull#_default_behaviour

Explanation and Examples

Upvotes: 16

techExplorer
techExplorer

Reputation: 908

Try cleaning-up your local repository with and then run git pull:

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

Upvotes: 5

Amber
Amber

Reputation: 526533

If you always want your server version to reflect a commit from your repo, it's probably better to use git reset instead of git pull - that way you never invoke merge functionality, but instead set all of the files to exactly what they are in the commit you reset to. For example:

git fetch origin master
git reset --hard FETCH_HEAD

Upvotes: 219

Related Questions