DEV Community

Cover image for How to get Clone a private Github repo!?
‪Kareem Negm‬‏
‪Kareem Negm‬‏

Posted on

9 2

How to get Clone a private Github repo!?

Hello all, this is my first post on dev.to community

I had a simple problem with git clone a private repo to my desktop, I tried many commands from StackOverflow and other websites and issues from GitHub, and nothing my issue not solved

today I solved my problem and want to share my solution with you

everything is about the access token to get access now,

Create Personal Access Token on Github

From your Github account, go to Settings => Developer Settings => Personal Access Token => Generate New Token (Give your password) => Fillup the form => click Generate token => Copy the generated Token, it will be something like ghp_sFhFsSHhTzMDreGRLjmks4Tzuzgthdvfsrta

after that in your command type

https://<PERSONAL-ACCESS-TOKEN>@github.com/<user_name"the owner user name " >/<repo_name>.git

that's it, your repo will get cloned correctly and without any disruptions

I hope you will find my post is Interesting and if you have any comments feel free to comment or commit;)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (7)

Collapse
 
chuniversiteit profile image
Chun Fei Lung

This works!

Alternatively, you can use SSH keys. They’re a bit safer, as you don’t end up with secrets (your personal access token) in your history.

Windows/macOS users who are looking for a really easy solution can just use the GitHub Desktop client to clone private GitHub repositories (you can still use git for other Git operations if you prefer the CLI).

Collapse
 
molly_1024 profile image
Molly

Thanks for this post!
But how to deal with evenytime should login again when use git command(like git commit/git push...)?

Image description

Collapse
 
dulanka profile image
dulanka

Thank you so much for this <3 I literally spent hours looking for a fix thanks again

Collapse
 
vulieumang profile image
Vu

Thank you, perfect

Collapse
 
lorenzocm profile image
Lorenzo Castillo

Nice! I was having issues to clone a private repo and this worked perfectly!

Collapse
 
chuniversiteit profile image
Chun Fei Lung

If you can clone the private repository and your account has write access, you can also do virtually all the other things you usually do with public Git repositories without any further steps.

Collapse
 
bigboss298 profile image
Bigbosss

Will it work even if it is not my repo, I have been sent an invitation from a private repo and I have been having issues cloning it

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay