Reputation: 988
I was creating a new Vue app and used 'vue create testapp'. I selected the typical defaults and it initialized the directory for git. Fine. I changed the directory to the project's directory and typed 'git status', I get the following:
On branch master
nothing to commit, working tree clean
When I did 'git add .', I get the following:
On branch master
nothing to commit, working tree clean
Nothing was added even though the directory contains files:
babel.config.js jsconfig.json node_modules/ package.json package-lock.json public/ README.md src/ vue.config.js
If I delete the .git directory and re-run 'git init' git will work properly.
What's wrong? Thank you in advance!
Upvotes: 1
Views: 97
Reputation: 98
In most projects created using CLI, such as create react app/vue cli, using git means all the contents of the initialized project will be automatically committed once, with init
as the commit message.
This means that we don't need to manually commit for the first time.
You can use git log
to view the history, and there will be a 'init' as the first and only commit.
If changes are made after initialization, git add
will take effect.
If you are curious about how Vue CLI handles it here, you can refer to the following code: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli/lib/Creator.js#L241-L256
// commit initial state
let gitCommitFailed = false
if (shouldInitGit) {
await run('git add -A')
if (isTestOrDebug) {
await run('git', ['config', 'user.name', 'test'])
await run('git', ['config', 'user.email', '[email protected]'])
await run('git', ['config', 'commit.gpgSign', 'false'])
}
const msg = typeof cliOptions.git === 'string' ? cliOptions.git : 'init'
try {
await run('git', ['commit', '-m', msg, '--no-verify'])
} catch (e) {
gitCommitFailed = true
}
}
Upvotes: 0
Reputation: 8623
The vue create command initializes a project with Git by default in the current @vue/cli
version.
You can check the commit detail via the following command:
git log
This means there is already an initial commit in your local repository, typically with a commit message like init
, but it has not been pushed to a remote repository yet.
To push the repository to a remote, you need to set the remote origin URL with the following command:
git remote set-url origin xxx.git
Then, you can push the repository to the remote with:
git push origin branchName
If you want to skip the Git initialization, you could run the command with param --no-git
or -n
:
vue create my-app --no-git
Important notice:
Vue CLI is in Maintenance Mode!
For new projects, it is now recommended to use create-vue
to scaffold Vite-based
projects.
Upvotes: 1
Reputation: 524
I think your files are already being tracked by git. You can check this using git ls-files
.
Try adding a dummy file and running git status
. It should show up as an untracked file.
You can check what the current remote is with git remote -v
.
Upvotes: 1