'git fetch shows nothing on console

We are following this model of using git: http://nvie.com/posts/a-successful-git-branching-model/

I'm trying to learn to use git fetch and git merge on the specific merge instead of just pulling. For my question, what I did was made changes to a branch and pushed those changes to the branch. I see those changes on github. Then I switch to master to fetch those changes. So I

git checkout master
git fetch  // terminal shows nothing
git fetch origin  // terminal shows nothing

Am I using the commands correctly for fetching? I don't see anything on the console. But then when I use a tool like SourceTree, and I fetch, it updates their tree and I can see the changes.

Assuming I get this next step to work, and I see the different changes were made, do I just do a git merge <hash of the last commit or commit I want to merge in>? Thanks!

git


Solution 1:[1]

git fetch or git fetch origin are fine, but if there is nothing to do, nothing is displayed.

You can use git fetch -v to be more verbose and display more informations

Solution 2:[2]

I found this because I was having a similar problem. I don't know the whys, but in my case I needed to explicitly name the branch which was updated:

$ git fetch [origin] [branch]

Let me explain--I use git for small scripts. I start the repo with master. After the script is deployed in production, and I still want to work on it, I will make a dev branch. But most projects just have one branch, or I just don't keep dev once merged.

Today, I updated remote master with a few minor changes, and wanted to update my local system with the changes. Out of habit, I just did $ git fetch. Nothing happened. Then I found your post. First, I added the project name (origin) and did $ git fetch [origin]. This updated both dev and master to the last time they shared a merge back in January. Then, OH! I ran $ git fetch [origin] master, and the changes were now downloaded.

Solution 3:[3]

You might be using the Git repository HTTP URL and, depending on how the authentication and network are set up, you should use the Git URL instead.

If your Git-remote is called origin:

  • First check that the assumption is correct, via git remote get-url origin.
    If HTTP, it will return something like https://gitlab.yourdomain.net/repoGroupFoo/repoBar.
  • Go on the repository via Web, click on the "Clone" button and you'll see two URLs; copy the URL that uses Git protocol instead of HTTP.
    Or simply build it up starting from the HTTP URL components: like from https://gitlab.yourdomain.net/repoGroupFoo/repoBar ?? to [email protected]:repoGroupFoo:repoBar.git.
  • Change protocol via git remote set-url origin [email protected]:repoGroupFoo:repoBar.git

Try git fetch again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Asenar
Solution 2
Solution 3 Kamafeather