git clone: Authentication failed for

I was facing same error when I was trying to clone a repository on a PC with freshly installed operating system. I was using Git bash as my Git client. When I ran Git’s command to clone a repository it was not prompting me for user id and password which will be used for authentication. It was … Read more

Git and nasty “error: cannot lock existing info/refs fatal”

For me this worked (won’t change in remote): git remote prune origin Since this answer seems to help a lot of people, I dug a little bit into what actually happens here. What this will do is remove references to remote branches in the folder .git/refs/remotes/origin. So this will not affect your local branches and it … Read more

fatal: Not a valid object name: ‘master’

When I git init a folder it doesn’t create a master branch This is true, and expected behaviour. Git will not create a master branch until you commit something. When I do git –bare init it creates the files. A non-bare git init will also create the same files, in a hidden .git directory in the root of your project. When I type git branch master it … Read more

master branch and ‘origin/master’ have diverged, how to ‘undiverge’ branches’?

You can review the differences with a: before pulling it (fetch + merge) (see also “How do you get git to always pull from a specific branch?”) When you have a message like: “Your branch and ‘origin/master’ have diverged, # and have 1 and 1 different commit(s) each, respectively.” , check if you need to update origin. If origin is up-to-date, then some commits … Read more

Download a single folder or directory from a GitHub repo

Update Apr. 2021: there are a few tools created by the community that can do this for you: Download Directory (Credits to fregante) It has also been integrated into the excellent Refined Github chrome extension as a button in the Github web UI. GitZip (Credits to Kino – see his answer here) DownGit (Credits to Minhas Kamal – see his answer here) Note: if you’re trying to download a … Read more