But I get an error "! [rejected]" and something about "non fast forward"

That's because Git can't merge the changes from the branches into your current master. Let's say you've checked out branch master, and you want to merge in the remote branch other-branch. When you do this:

$ git pull origin other-branch

Git is basically doing this:

$ git fetch origin other-branch && git merge other-branch

That is, a pull is just a fetch followed by a merge. However, when pull-ing, Git will only merge other-branch if it can perform a fast-forward merge. A fast-forward merge is a merge in which the head of the branch you are trying to merge into is a direct descendent of the head of the branch you want to merge. For example, if you have this history tree, then merging other-branch would result in a fast-forward merge:

O-O-O-O-O-O
^         ^
master    other-branch

However, this would not be a fast-forward merge:

    v master
O-O-O
\
 \-O-O-O-O
         ^ other-branch

To solve your problem, first fetch the remote branch:

$ git fetch origin other-branch

Then merge it into your current branch (I'll assume that's master), and fix any merge conflicts:

$ git merge origin/other-branch
# Fix merge conflicts, if they occur
# Add merge conflict fixes
$ git commit    # And commit the merge!
Answer from mipadi on Stack Overflow
Top answer
1 of 16
1089

But I get an error "! [rejected]" and something about "non fast forward"

That's because Git can't merge the changes from the branches into your current master. Let's say you've checked out branch master, and you want to merge in the remote branch other-branch. When you do this:

$ git pull origin other-branch

Git is basically doing this:

$ git fetch origin other-branch && git merge other-branch

That is, a pull is just a fetch followed by a merge. However, when pull-ing, Git will only merge other-branch if it can perform a fast-forward merge. A fast-forward merge is a merge in which the head of the branch you are trying to merge into is a direct descendent of the head of the branch you want to merge. For example, if you have this history tree, then merging other-branch would result in a fast-forward merge:

O-O-O-O-O-O
^         ^
master    other-branch

However, this would not be a fast-forward merge:

    v master
O-O-O
\
 \-O-O-O-O
         ^ other-branch

To solve your problem, first fetch the remote branch:

$ git fetch origin other-branch

Then merge it into your current branch (I'll assume that's master), and fix any merge conflicts:

$ git merge origin/other-branch
# Fix merge conflicts, if they occur
# Add merge conflict fixes
$ git commit    # And commit the merge!
2 of 16
413

Simply track your remote branches explicitly and a simple git pull will do just what you want:

git branch -f remote_branch_name origin/remote_branch_name
git checkout remote_branch_name

The latter is a local operation.

Or even more fitting in with the GitHub documentation on forking:

git branch -f new_local_branch_name upstream/remote_branch_name
๐ŸŒ
Git
git-scm.com โ€บ docs โ€บ git-pull
Git - git-pull Documentation
For more information, see branch.<name>.merge and branch.<name>.remote in git-config[1]. ... When given, and the repository to fetch from is handled by git fetch-pack, --exec=<upload-pack> is passed to the command to specify non-default path for the command run on the other end.
Discussions

using git pull on a branch other than main.
Two things: a) pull pulls always into the currently checked-out branch. It is possible to eg. pull origin/master into (local) featureX branch, but this is rarely what beginners want. So you cannot omit the switch. b) the full format is git pull [repo [refspec]]. If you omit the repo and refspec, the default is taken to be the tracked branch, if set up โ€“ else there are different config options to set the default; they are a bit convoluted, I suggest you consult the manpages for pull and config if you need to. In short: it should have worked if you set up a tracking branch. Did you? Or do you by chance have two different remotes? Difficult to troubleshoot without further info. More on reddit.com
๐ŸŒ r/git
2
1
October 27, 2022
version control - How do I git pull a dev branch? - Drupal Answers
I would read a Git tutorial or two first; it will definitely pay off in saving you time later. ... The way to pull the repository for the 7.x-3.x branch of the Views module (i.e. the development snapshot 7.x-3.x-dev for the Views module) from Drupal.org for the first time is executing the following command... More on drupal.stackexchange.com
๐ŸŒ drupal.stackexchange.com
April 30, 2012
How to overwrite local changes from remote repository?
I don't believe there is a way to do this with 1 command, there is no option for clone that allows it to override existing files. You could have a script that force pulls if the local repo exists and clones if it doesn't. More on reddit.com
๐ŸŒ r/git
5
8
March 11, 2022
practical advice on git config pull.rebase true/false?
I think the best โ€“ because safest โ€“ default is pull.ff=only. Fast-forward pulls are what one expects 99% of the time, and if not, I want it to tell me! Then it's easy to redo it with a pull --rebase=(false|true) or whatever. Edit: Also fast-forwards always work, no matter how much time went by since your last pull. Pulling new changes imo should always be easily possible, because else you're gonna delay it even more. If a pull leads to massive conflicts, it's usually not because you haven't pulled in a long time, but because you haven't pushed your changes up for long. Then just put them in a secondary branch, reset the main one, pull, and then decide if you're gonna rebase, merge, cherry-pick only a few, or start from fresh. More on reddit.com
๐ŸŒ r/git
10
5
February 11, 2025
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ git โ€บ how-to-git-pull-from-a-specific-branch
Pulling Changes from a Specific Branch in Git - GeeksforGeeks
February 26, 2026 - Replace <branch_name> with the name of the target branch: ... Run git pull <remote> <branch> on the target branch; explicitly specifying the remote and branch improves clarity in collaborative workflows.
๐ŸŒ
W3Schools
w3schools.com โ€บ git โ€บ git_branch_pull_from_remote.asp
Git Pull Branch from Remote
git checkout html-skeleton Switched to a new branch 'html-skeleton' Branch 'html-skeleton' set up to track remote branch 'html-skeleton' from 'origin'. And check if it is all up to date: git pull Already up to date. Which branches do we have ...
๐ŸŒ
CloudBees
cloudbees.com โ€บ blog โ€บ git-pull-how-it-works-with-detailed-examples
Git Pull: How It Works With Detailed Examples
July 9, 2021 - Finally, run git pull to update your local branch. Before wrapping up, letโ€™s answer another common question: Whatโ€™s the relationship between the pull operation in Git and the concept of a pull request? Well, git pull is a native command from Git. A pull request, on the other hand, is a feature from GitHub.
Top answer
1 of 4
5

If I do

git clone --recursive --branch 7.x-3.x http://git.drupal.org/project/views.git

and then

git branch -r

I get

origin/4.6.x-1.x  
origin/4.7.x-1.x  
origin/5.x-1.x  
origin/6.x-2.11-security  
origin/6.x-2.x  
origin/6.x-3.x  
origin/7.x-3.x  
origin/8.x-3.x  
origin/HEAD -> origin/7.x-3.x  
origin/d7v3ui  
origin/master  

I believe you need the recursive flag to get all remotes. Not sure if you did that, but a quick git fetch will update your list of remotes.

git pull origin 7.x-3.x-dev
fatal: Couldn't find remote ref 7.x-3.x-dev
Unexpected end of command stream 

I think this is just due to the naming conventions, current dev is HEAD afaik.

git pull origin 7.x-3.x
From http://git.drupal.org/project/views
 * branch            7.x-3.x    -> FETCH_HEAD
Already up-to-date.

I believe that any branch (not tag) can be considered 'dev' for that drupal version.

Hope this helps.

2 of 4
6

I'm not a Git expert, but as I understand it all of the releases of the dev branch listed on the project page are made directly to the 7.x-3.x branch. Of course you're free to create your own branches locally for your own needs, but the master-like branch, which includes all of the releases pushed to drupal.org, is always going to be that 7.x-3.x branch.

If you want to switch to one of the tagged releases, use git tag to get a list of all the releases. Then, to check out the 7.x-3.1 release (for example), use git co 7.x-3.1.

If you intend to edit the code for this release, you can then create a new branch (as Git explains) by using git checkout -b mycustombranch.

Find elsewhere
๐ŸŒ
Atlassian
atlassian.com โ€บ git โ€บ tutorials โ€บ syncing โ€บ git pull
How to Pull a Git Repository? | Atlassian Git Tutorial
The git pull command is actually a combination of two other commands, git fetch followed by git merge. In the first stage of operation git pull will execute a git fetch scoped to the local branch that HEAD is pointed at.
๐ŸŒ
Graphite
graphite.com โ€บ guides โ€บ git-pull-remote-branches
Git pull remote branches
Fetch: The command git fetch downloads ... them into your current working files. Pull: The command git pull is essentially a combination of git fetch followed by git merge....
๐ŸŒ
LinkedIn
linkedin.com โ€บ pulse โ€บ ultimate-guide-pulling-from-different-branches-git-cengkuru-michael
The Ultimate Guide to Pulling from Different Branches in Git
December 18, 2022 - If you want to specify a different remote or local branch to merge the changes into, you can use the โ€” rebase flag and specify the remote and branch names after it. For example: git pull --rebase origin my-feature my-local-branch
๐ŸŒ
GitHub
github.com โ€บ git-guides โ€บ git-pull
Git Guides - git pull ยท GitHub
You can update your local working branch with commits from the remote, but rewrite history so any local commits occur after all new commits coming from the remote, avoiding a merge commit. This is done with git pull --rebase.
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ git โ€บ fetch and pull all branches in git
Fetch and pull all branches in Git | Sentry
These branches will now show up in the output of git branch and can be checked out, committed to, pulled and pushed. If we only need to view the remote branches, and not work on them, we can use git fetch instead: ... We will then be able to ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ git โ€บ git-pull-force
Git Pull Force - GeeksforGeeks
August 26, 2024 - The git pull command is a combination of git fetch and git merge. It fetches updates from the remote repository and merges them into your local branch.
๐ŸŒ
Coding Bash
codingbash.com โ€บ tutorial โ€บ how-to-use-git-pull-command-in-git-bash
Git Pull
For example, -v for verbose which provides the detailed message logs while pulling the files from the remote repository, -q for the quiet, -r for the rebase which incorporates the changes by rebasing rather than merging, etc. Use the โ€œgit pull ...
๐ŸŒ
Git LFS
git-lfs.com
Git Large File Storage | Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise.
Download less data. This means faster cloning and fetching from repositories that deal with large files. Work like you always do on Gitโ€”no need for additional commands, secondary storage systems, or toolsets.
๐ŸŒ
Gitopia
docs.gitopia.com โ€บ git tutorials โ€บ git commands โ€บ git pull
Git Pull | Gitopia
It is one of the four commands that prompts network interaction by Git. By default, git pull does two things - Updates the current local working branch (currently checked out branch)
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ git โ€บ git-pull-remote-branch
Git Pull Remote Branch - GeeksforGeeks
February 26, 2026 - Common commands to sync local branches with remote changes and manage remote branches. git pull <remote> <branch>: Fetches changes from the specified remote branch and merges them into your current branch.
๐ŸŒ
TheServerSide
theserverside.com โ€บ blog โ€บ Coffee-Talk-Java-News-Stories-and-Opinions โ€บ Git-pull-vs-fetch-Whats-the-difference
Git pull vs fetch: What's the difference?
The local Git repository where the history of all commits across all branches are maintained. A working directory where a developer actively edits and updates files that Git tracks. A git pull operation is equivalent to a git fetch and merge. If a developer finds out that there are new, updated files on a remote repository like GitHub, they will likely want to copy those changes from GitHub to both their local repository and into their working directory. This is what the git pull command does.
๐ŸŒ
GitHub
docs.github.com โ€บ articles โ€บ checking-out-pull-requests-locally
Checking out pull requests locally - GitHub Docs
Create a new pull request with your new branch. The remote refs/pull/ namespace is read-only. If you try to push commits there, you'll see this error: ! [remote rejected] HEAD -> refs/pull/1/head (deny updating a hidden ref) error: failed to ...
๐ŸŒ
Intellipaat
intellipaat.com โ€บ home โ€บ blog โ€บ git pull: usage, rebase, conflicts & examples
Git Pull Explained: Usage, Rebase, Conflicts & Examples
September 19, 2025 - It combines two steps behind the ... to your current branch. A git pull is a Git command that fetches and merges changes from a remote repository into your local branch....