Copiar solo parte de un repositorio

Aprende a extraer solo una subcarpeta de un repositorio Git sin historial: descarga manual, git archive o curl. Ideal para plantillas y pruebas de concepto.

3 sept 2025 • 2 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Estaba haciendo unas pruebas de concepto y quería iniciar un nuevo proyecto a partir de una parte concreta de un repositorio. Copiar una carpeta tal cual puede arrastrar el historial y los archivos de control de git, algo que no me interesa. A continuación comparto tres formas sencillas de extraer solo una subcarpeta de un repositorio sin traer el .git.

Opción manual

En cualquier repositorio de GitHub puedes descargar el contenido como archivo zip desde la opción Code y luego Download ZIP. Descomprime el zip, copia la subcarpeta que necesitas dentro de tu nuevo repositorio y realiza un git init si aún no lo has hecho. Con eso ya puedes continuar tu desarrollo sin el historial anterior.

Git archive desde terminal

El comando git archive permite extraer archivos de un repositorio remoto sin clonar todo. Puedes conectarte por https o por ssh. Indica el remote, el branch y la ruta de la subcarpeta que quieres traer; la salida la enviamos a tar para extraer directamente en la carpeta actual.

https: git archive --remote=https://github.com/dwildt/gosandbox.git main vibe-certificados | tar -x

ssh: git archive --remote=git@github.com:dwildt/gosandbox.git main vibe-certificados | tar -x

Via curl

También puedes descargar un tar comprimido del branch y extraer solo la subcarpeta deseada con strip-components. Ejemplo en un repo público:

curl -L https://github.com/dwildt/gosandbox/archive/main.tar.gz | tar -xz --strip-components=1 gosandbox-main/vibe-certificados

Si el repositorio es público, este método funciona sin autenticación. Para repos privados necesitarás un token o acceso ssh. En mi caso, el objetivo era tomar el contenido del test llamado vibe-certificados y convertirlo en un nuevo repositorio independiente. Cualquiera de las tres opciones cumple el objetivo sin arrastrar el historial.

Consejos prácticos

1. Asegúrate de estar en una carpeta vacía antes de extraer con tar si no quieres mezclar archivos. 2. Si vas a reutilizar esta técnica a menudo, crea un pequeño script que reciba repo, branch y ruta para automatizar el proceso. 3. Una vez extraído, ejecuta git init, crea tu primer commit y define tu nuevo remoto.

Cómo encaja esto en flujos de trabajo reales

Estas técnicas son muy útiles para crear plantillas y boilerplates, separar módulos de un monorepo o simplificar pruebas de concepto. Facilitan la estandarización y la automatización, especialmente cuando trabajas con equipos que comparten assets comunes.

En Q2BSTUDIO ayudamos a equipos a acelerar su entrega con buenas prácticas de ingeniería y repositorios organizados, ya sea para aplicaciones a medida y software a medida, o para escalar la productividad mediante automatización de procesos y plantillas reutilizables. Además, integramos inteligencia artificial e IA para empresas con agentes IA, cuidamos la ciberseguridad desde el diseño, trabajamos con servicios cloud AWS y Azure, y potenciamos tus datos con servicios inteligencia de negocio y Power BI.

Si buscas un socio que combine desarrollo pragmático con innovación, Q2BSTUDIO es tu equipo. Podemos ayudarte a definir repositorios base, pipelines de CI, seguridad y observabilidad desde el inicio, para que tu producto crezca sólido y seguro con prácticas modernas de ingeniería y un enfoque de entrega continua.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat