Clone a repo with an empty history
(electronic sounds) - [Instructor] Let's begin with something that might be a bit handy for this course. How do you make a copy of an existing repo without copying any of its history, even if the repo is not yours? I'll give you a couple of seconds to pause the video and see how you would have solved it. (electronic sounds) All right, there's a few ways that we can do this. The tough part is that I want a clean history. That's not associated with the original repo. Now you could forge the repo, but you can only do that once. And then you'd still have a link to the original. Another way is to create a template repository, but you can only do that if you're the owner of the repository. But there's a much faster and flexible way. You can use a project called Degit by Rich Harris, the maker of this Vout framework. Degit lets you do exactly what we're looking for. We'll also need to use npx, which comes when you install NodeJS, the command looks like this. Now npx will allow you to temporarily use a project without having to download it so we can run the Degit project. From there, you can specify a GitHub username, although it defaults to GitHub. It will also work with other products like Bitbucket and GitLab by adding it as a prefix with a semi-colon. In addition to the username, you can specify a project's name. You can even choose to only copy an existing branch release or hash by adding that after a hashtag symbol, then finally you specify what you want to call the project locally, separating the name with a space. Let's try this command. I'm going to switch over to hyper, which is my terminal. I'm going to make sure that I switched to the desktop and then also issue the npx Degit command. And I'm going to target the LinkedIn learning group and then type in the name of the repository I want the copy. And then I'm going to enter the name that I want to call this locally. I'm going to hit enter. And I'm going to say yes right here. Now this is going to clone the repository to my desktop. Since this is a brand new repo, you'll still need to initialize git, create a repo and then push this to GitHub. But it's the fastest way to get started with a clean history. I'm going to be using something like this to copy clean GitHub projects. When I show you some of the other challenges.
内容
-
-
-
Clone a repo with an empty history2 分钟 28 秒
-
(已锁定)
How do you merge a linear history?4 分钟 22 秒
-
(已锁定)
Add an issue directly from the Terminal2 分钟 56 秒
-
(已锁定)
Deleting all commit history1 分钟 56 秒
-
(已锁定)
Fix a committed password4 分钟 32 秒
-
(已锁定)
Create a monorepo3 分钟 18 秒
-
(已锁定)
Update certain branches3 分钟 18 秒
-
(已锁定)
Process all branches3 分钟 48 秒
-
(已锁定)
Run accessibility audit on push6 分钟 43 秒
-
(已锁定)
Use hidden secrets in projects5 分钟 29 秒
-
(已锁定)
Run actions on a schedule3 分钟 13 秒
-
(已锁定)
Create a Docker container action5 分钟 25 秒
-
(已锁定)
Build and deploy your sites3 分钟 55 秒
-