Git本地文件夹关联远程仓库同时强制覆盖远程仓库的文件
如果已经通过 Git 创建了一个远程仓库,并且远程仓库中已经有一些文件(如README.md 等),而本地有一个文件夹,希望将本地文件夹与远程仓库关联,并强制覆盖远程仓库中的文件。
使用场景
比如通过github或gitee创建了一个远程仓库,自动初始化了一些文件。同时通过create-vue 或vite 创建了一个项目,如何和远程的仓库关联呢?
如何我们直接拉取远程仓库到本地,因为文件夹已经存在,不能直接使用
create-vue或vite命令。
具体操作
具体代码如下:
bash
git init
git add .
git commit -m "Initial commit with local files"
git push origin main --force
--force 是一种危险操作,因为它会强制覆盖远程仓库中的所有更改,可能会丢失远程仓库中的某些重要文件。如果你希望更安全地强制推送,可以使用
--force-with-lease
tailwindcss 4 集成vite报错:Failed to resolve "@tailwindcss/vite".
安装官网文档操作如下:
Install tailwindcss and @tailwindcss/vitevia npm.
bash
npm install tailwindcss @tailwindcss/vite
Configure the Vite plugin
bashit
# vite.config.ts
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(),
],
})
Import Tailwind CSS
Add an @import to your CSS file that imports Tailwind CSS.
bash
@import "tailwindcss";
以上是官网的集成步骤,然而启动后报错:
Failed to resolve "@tailwindcss/vite". This package is ESM only but it was tried to load by require. See https://vite.dev/guide/troubleshooting.html#this-package-is-esm-only for more details. [plugin externalize-deps]
解决方案
将 vite.config.js/vite.config.ts 重命名为 vite.config.mjs/vite.config.mts
Github镜像站, 2025年1月最新可用!国内更快部署下载(1月更新)
GitHub 镜像可用站点
| 镜像 | 访问 | 链接 | 可用 |
|---|---|---|---|
| GitHub镜像站014 | 直接 | https://bgithub.xyz | 可用 |
| GitHub镜像站013 | 直接 | https://kkgithub.com | 可用 |
| GitHub镜像站012 | 直接 | https://gitclone.com | 可用 |
| GitHub镜像站011 | 直接 | https://github.hscsec.cn | 不可用 |
| GitHub镜像站010 | 直接 | https://git.homegu.com | 不可用 |
| GitHub镜像站009 | 直接 | https://github.ur1.fun | 可用 |
请特别注意:
导航立足学术公益,仅为方便科研工作而提供学术网址导航。