DEV Community

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

Posted on

How to get Clone a private Github repo!?

Hello all, this is my first post on 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><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;)

Top comments (8)

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).

molly_1024 profile image

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

Image description

dulanka profile image

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

vulieumang profile image

Thank you, perfect

lorenzocm profile image
Lorenzo Castillo

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

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.

bigboss298 profile image

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