I am a newbie in git and currently trying out various combinations to understand git.
I have a repository with branch named 'dev'. Now initially i brought my local in sync with the remote. Then i changed the remote directly from Github.
Now if i use
git fetch origin dev:dev
then i receive an error
fatal: Refusing to fetch into current branch refs/heads/dev of non-bare repository
However, the following pull command works fine
git pull origin dev
In one of the Stackoverflow answer it was mentioned that fetch followed by merge was equivalent to git pull.
If it is so then why this discrepency ?
Question Link : understanding git fetch then merge
PS : The answer suggested from link below in comments is correct one. However i was wondering that
git fetch origin
fetches from all branches including the current one. Then why perform the check only in case of
git fetch origin master:master
I am not able to understand the reason behind this validation. Any help is appreciated.
Thanks