“Github Error: Permission to user/repo denied to user/other-repo”

Posted on in Git

Today I came across the following problem on my Github CLI interface on Windows 10:

"Error: Permission to user/repo denied to user/other-repo"

This error means the key you are pushing with is attached to another repository as a deploy key, and does not have access to the repository you are trying to push to.

I got this problem, because I tried to push to a different Github account than I usually do.

Technically, you should be able to add the user email to the git config like this:

git config user.name "Billy Everyteen"
# Set a new name
git config user.name
# Verify the setting
Billy Everyteen


git config --global --unset-all
#remove user configs

However, this didn't work for me. It still was using my old username.

This old username comes from your Git keys. You can just remove it from the Credential Manager (for a Mac OSX it's probably in the Key Chain tool).
The next time you make a Push with Git, it will ask again for your Github username and password.

For Windows you can find the keys here:

control panel > user accounts > credential manager > Windows credentials > Generic credentials

Next remove the Github keys.

Git Cheat Sheet

Posted on in Environment Git

Here’s a cheat sheet with all the Git command-line actions we can do:

Create a Git repo from the command line:

  • Go to https://github.com/mygitname?tab=repositories
    Create “New” repository. (for example myrepo)

  • Create .gitignore:

.project
.settings
.classpath
.idea

######################
# OS generated files #
######################

__MACOSX
.DS_Store
._*

.Spotlight-V100
.Trashes

ehthumbs.db
Thumbs.db

############
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
.DS_Store

############
# Sencha #
############

temp/
build/
.sencha_backup/
*slicer-temp*
gwt-unitCache
.sass-cache/

* Create project

  1. git init
  2. git status
  3. git add .
  4. git commit -m “First commit”
  5. git remote add origin https://github.com/username/myrepo.git
  6. git push -u origin master

Retrieve changes:
1. git pull

Commit changes:

  1. git pull
  2. git add .
  3. git commit -m “My commit description”
  4. git push

Commit removed files from the tree
> git commit -am “remove deleted files”

Removing changes:

Remove a single file:
> git rm filename

Remove files:
> git rm ‘*.txt’

Remove a Folder:
> git rm -r myfolder

Reset unstaged files:
> git reset myfilename

Force to remove:
> git rm —force myfile
Or:
> git rm f myfile

Adding changes:

Add a file:
> git add myfilename

Add files with a wildcard:
> git add ‘*.txt’

Add everything in a directory:
> git add -A .

Create a branch:

Create a branch:
1. git brand mybranch
Switch to the new branch:
2. git checkout mybranch
Merge branch with master:
3. git merge mybranch

Remove a branch:
> git branch -d mybranch

Create and switch to the new branch:
> git checkout -b mybranch

Retrieve changes from master branch
> git pull -origin master

Push to master branch
> git push -u origin master

More Commands:

Check status:
> git status

See log, to see what’s changed:
> git log

See differences in file with merge errors
> git diff HEAD

See differences between a stage file and what’s in git
> git diff —staged

Files can be changed back to how they were at the last commit
> git checkout — myfilename

Close the command-line

Remove all those annoying *.DS_Store files:

  1. find . -name '*.DS_Store' -type f -delete
  2. git commit -m “Remove .DS_Store files”
  3. git push

Save GIT credentials to the keychain (MAC OSX)
Make sure osxkeychain is installed;
(check this site for more information)

> git config --global credential.helper osxkeychain

Hard reset to the latest version in Head
(note: you might want to backup your local files here, cause these will get lost)
> git reset --hard HEAD
> git clean -f
> git pull

Fix GIT Http Error

Posted on in Environment

Suddenly my Git Mac Client starts throwing the error message: "No internet connection" every time I sync my repo.
But I did have an internet connection! I tried it again, but this time on the command line; with a git push.
If git gives an error that reads "fatal: The remote end hung up unexpectedly", it usually indicates that your HTTP POST buffer is too small to handle the files being posted. Try increasing the buffer size by running the following command on the command line:

git config http.postBuffer 524288000