-3

I have been trying to run a batch file that will fetch all branches from a predefined repo and checkout one of the branches.

git fetch --all
git checkout myBranch
pause

The response I get from the command line is that the commands run successfully but the folder I ran the file in, shows no evidence of having checkout any branch.

I have also tried checking out to the path of the folder and running the commands, still to no avail.

However, when I write the commands into the cmd it works correctly.

Any help will be much appreciated

GavClarke
  • 47
  • 1
  • 5
  • Is `myrepo` a branch name or a repository? – jwdonahue Mar 29 '18 at 21:10
  • Take the [tour], read [Ask] and [MCVE]. It would help if you could cut & paste the observed output into your original post. Click on [Edit]. – jwdonahue Mar 29 '18 at 21:14
  • What do you mean by "_checkout one of the repos_"? Do you want to **clone** a _repo_ OR do you want to **checkout** a _branch_? – Gino Mempin Mar 29 '18 at 23:39
  • sorry misspoke myrepo mean the branch i was checking out and i did use the git fetch --all the single - was a typo – GavClarke Mar 30 '18 at 10:31
  • Please edit your post to fix this typo: "_i did use the git fetch --all the single - was a typo_". Then, also post the console output when you run the batch file. Chances are, you're checking out a non-existent branch. – Gino Mempin Apr 02 '18 at 04:22

3 Answers3

2

git fetch --all (double -) fetches from all remotes, not all branches. fetch always fetches all branches. (For git push you Need the parameter --all to push all branches.)

git checkout myrepo tries to checkout a branch called myrepo. Probably no branch of this name exists, so an error should be shown.

milbrandt
  • 1,438
  • 2
  • 15
  • 20
-2

what do you mean by 'shows no evidence of having checkout any repo' ?

When you run your batch, don't you see a message like Switched to branche.. or already on .. ?

adam66
  • 77
  • 3
-2

A previous answer indicates the commands cmd "/C clean.bat" or ./clear.bat will give you your desired result.

Jerel
  • 123
  • 1
  • 4