nirvdrum / svn2git

Ruby tool for importing existing svn projects into git.
MIT License
2.11k stars 443 forks source link

error: pathspec 'master' did not match any file(s) known to git #306

Open asthagangwar3 opened 2 years ago

asthagangwar3 commented 2 years ago

using svn2git for migrating svn to git but getting below error,

\MYProject\Demo>svn2git https://shwetakhai-w10.cybage.com:8443/svn/SVN2GIT/ --authors authors.txt -v Running command: git svn init --prefix=svn/ --no-metadata --trunk='trunk' --tags='tags' --branches='branches' https://shwetakhai-w10.cybage.com:8443/svn/SVN2GIT/ Initialized empty Git repository in D:/MYProject/Demo/.git/ Running command: git config --local --get user.name Running command: git config --local svn.authorsfile authors.txt Running command: git svn fetch Running command: git branch -l --no-color Running command: git branch -r --no-color Running command: git config --local --get user.name Running command: git config --local --get user.email Running command: git checkout -f master error: pathspec 'master' did not match any file(s) known to git command failed: git checkout -f master

ghost commented 2 years ago

Had the same issue and svn2git didn't work for me at all.

I managed to migrate using the steps outlined here https://gist.github.com/leftclickben/322b7a3042cbe97ed2af

swaroopbekal commented 2 years ago

Looks like git svn fetch failed. You can try to figure out why it failed by running it manually.

ams-tschoening commented 2 years ago

Current versions of GIT don't create a master branch anymore by default, but a main one. It might simply happen that your tooling is recent enough that svn2git doesn't support this change anymore.

https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/

zedseven commented 2 years ago

To add to the comment above, you may be able to get around this by running git config --global init.defaultBranch master and re-running svn2git. (make sure to change it back to main afterwards if that's something you care about)

I'm attempting this currently, but it'll be another 16 hours before I know if it was successful, since this error occurs after the git svn fetch. :)

zedseven commented 2 years ago

It doesn't seem like my previous suggestion worked (after another ~16 hours).

I forked this repo and changed it so that it looks for main now instead of master – I'm going to try that, and anyone else is welcome to try it too: https://github.com/zedseven/svn2git

JokaHD commented 2 years ago

Hi @zedseven,

I've test your forked repo on my svn repo successfully after I update git to the latest version and add --nobranches . Thanks!!

skull-squadron commented 9 months ago

Instead of getting into default branch name holy wars or a compatibility excretion contest by making a fragile assumption, I've found this pattern to work without modifying svn2git:

mkdir {{your_repo}}
cd {{your_repo}}
git init -b master
svn2git ....

This has the advantage of not modifying git global defaults or changing svn2git which would require multiple layers of up- and downstream release processes to arrive as a standard system package. A more robust fix would be for svn2git to check which branch git created rather than assuming it because it will break in environments where the default branch is something else.