-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

5
  • Is myrepo a branch name or a repository? Commented Mar 29, 2018 at 21:10
  • Take the tour, read How to Ask and minimal reproducible example. It would help if you could cut & paste the observed output into your original post. Click on Edit. Commented Mar 29, 2018 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? Commented Mar 29, 2018 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 Commented Mar 30, 2018 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. Commented Apr 2, 2018 at 4:22

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

-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 .. ?

1 Comment

sorry my repo was a typo i meant a branch that i was trying to checkout
-2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.