Categories
Git Tutorials

Another Way to Clone a repo

I just created my first ever repo with a boilerplate code. It consist of pixijs and essentials. This article explains a different approach to clone a repo

If you don’t want to go through the story than just jump to following section for the meat and butter of this post

It is quite a norm for me to go through following workflow for 2d graphics project

  1. Create folder
  2. Npm inkt
  3. Initialize empty git repo
  4. Install pixijs
  5. Install pixi-viewport
  6. Add typescript
  7. Add parcel bundler
  8. Write some minimal code to run a working demo
  9. Push initial commit

It was quite daunting to go through these steps. Only than I realized a need of some kind of automation. There is no better way but to wrap it in a package.

After pushing it to the GitHub, now is a moment of truth to use it in another project. I am working on pixi-grid. Did I described what’s Pixijs.

Pixijs

It’s a 2d graphic tool. It is quite flexible with WebGL renderer. The renderer will fallback to HTML5 canvas if WebGL isn’t supported. Flash Action script can easily jump into Graphics on the web with this tool

So pixi-grid will have some advanced features, infinite will be one of them. So I clone a repo in a folder called it pixi-grid using following command

    git clone https://technbuzz/pixi-boilerplate .

This clones the project a current folder, all is set now I just need to run npm install to run the new project.

I ran the app everything is working, I made some changes and tried to publish this new repos as a Github project, since VSCode made it really easy to publish to Github. You don’t need to visit the Github online all can be done right from the Visual Studio Code

Clone a bare repo and publish it to github right from Visual Studio Code from technbuzz
Visual Studio Code has this command which directly publishes git project to Github

As soon I published, and pushed some changes, I didn’t found any changes on the remote pixi-grid. It was still displaying this template of empty repo with some instructions to get going.

I tried to make another change but to no avail.

After 2000 hours of computer years later, I found that remote origin was set to that of original boilerplate repo, the one that is used as a blueprint for pixijs project. So every assumed push of pixi-grid was going to pixi-boilerplate

Clone a repo with – -bare

When we clone a bare repo we only get the .git folder. It doesn’t have a working tree, it can be edited directly. It doesn’t have remote set. Here is the more information. In order to achieve we need to execute the following command

git clone --bare https://github.com/technbuzz/pixi-boilerplate.git .git

Now we have that, next we need to modify a git config variable core.bare which is a Boolean. This following command will convert it to a normal repo

git config --bool core.bare false

Now all we have to do is to reset the head pointer.

git reset --hard

Now that’s it, now I am not gonna accidently push to wrong remote. Because in my case I was the owner of both the repo. But you do need to add proper remotes.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.