How to move .gitignore file from one branch to another from commandline

Viewed 150

I have created and pasted a .gitignore file to my master branch, and I want to move it to the hometask_1 branch with the windows 10 command line.

I have used the commands below:

git checkout master
git checkout hometask_1 -- .gitignore

After the above commands I am getting the following error:

error: pathspec '.gitignore' did not match any file(s) known to git

1 Answers

From this answer, you can move a file from one branch to another with: git checkout otherbranch myfile.txt from the branch where you want the file to end up.

In your case, from the hometask_1 branch, you can run: git checkout master .gitignore.

Related