Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How come "git pull origin master" doesn't actually change the files in my computer's directory?

I'm still quite new to GitHub, though I'm in a position where I have to actively use it.

Anyway, I used "git pull upstream master" to pull and merge the latest code for the project I'm working on. I thought this command would update the actual files on my computer (the ones that appear in the directory, etc.), but instead, nothing happens.

Sure the console mentions many changes, but none of them seemed to have happened. As an experiment, I even deleted everything from one of the files and re-pulled to see if this would change, but I get "already up-do-date".

If it helps, I typed in git branch -v and got the following:

* master a2e10a4 [ahead 29] git workflow experiment

Also, git status gives the following:

# On branch master
# Your branch is ahead of 'origin/master' by 29 commits.
#
nothing to commit (working directory clean)

As a final note, my only branch is master.

What is going on and how do I get "pulled" changes to show up on my directory/computer?

like image 507
user1971506 Avatar asked Mar 12 '13 20:03

user1971506


People also ask

Why is git pull not updating?

git pull Not Updating Files Due to Uncommitted Files in Your Local Repository. As a source code management system, Git does its best to prevent you from losing your files and data. For this reason, Git may refuse to merge your local files with files from your remote repository when performing the git pull command.

How do you pull changes from origin master?

To answer your question, the git pull origin master will pull changes from the origin remote, master branch and merge them to the locally checked-out branch. However, the git pull origin/master will pull changes from the locally stored branch origin/master and merge that to the local checked-out branch.

Does git pull origin master overwrite local changes?

The reason for error messages like these is rather simple: you have local changes that would be overwritten by the incoming new changes that a "git pull" would bring in. For obvious safety reasons, Git will never simply overwrite your changes.

Why git pull is not working?

Not enough information for Git to work with As the error message states: you will have to let Git know what remote branch it should use to track with the current local branch. Doing this will allow you to simply run git pull and Git will know where to bring new data from.


2 Answers

I suspect master isn't tracking upstream/master (as in here), which means, a git pull upstream master only fetches commit from upstream, but doesn't merge anything.
You could merge those manually: git merge upstream/master.

Plus, upstream isn't origin, and master is ahead from origin/master: There is nothing to pull here, only 29 new commits to push to origin (which should be your fork, that is your clone from upstream on the GitHub server side: see "What is the difference between origin and upstream on GitHub?").

Fork and upstream

like image 200
VonC Avatar answered Oct 20 '22 17:10

VonC


The command you typed was git pull upstream master. That command fetches and then merges changes from the upstream to your local branch.

The git status message indicates that everything in your upstream has already been merged with your local master. But you haven't pushed your changes to the remote yet. In other words, you've committed your changes to the local repository, but you haven't pushed them to the remote yet. In a distributed VCS like git, commit and push are not the same thing.

Type git push origin master to send your changes to the upstream remote. This will get everything synched up.

If that doesn't work you may need to rebase your local repository. To rebase the remote origin under your local work, type git pull -r origin master. Then type git push origin master.

If you're not sure whether you're ready to push or not you can always do a dry run with git push origin master --dry-run and none of your changes will actually be pushed.

like image 42
Gui LeFlea Avatar answered Oct 20 '22 19:10

Gui LeFlea