Reputation: 455
I want to create a batch file to execute a set of Git commands to:
Second Git command uses a forward slash (origin/[repositoryName]
) and gives the following error:
"fatal: Missing branch name; try
-b
".
@ECHO OFF
SET /P branch = Enter remote branch name:
git fetch origin %branch%
git checkout --track origin/%branch%
First, git
command fetches the remote repository.
Second git
command gives error:
"fatal: "Missing branch name; try
-b
"
Upvotes: 0
Views: 177
Reputation: 5518
As mentioned in comments you should use the following piece of code:
@echo off
set /p "branch=Enter remote branch name: "
git fetch origin %branch%
git checkout --track origin/%branch%
which is slightly modified.
=
. Because then, interpreter interprets it as var<space>
and <space>value
.set "var=value"
.Upvotes: 2