Git

OSX: Upgrade Preinstalled Git on OSX

Git just announced latest version git 2.10 with several improvement. Here is how to upgrade preinstalled git on OSX to latest version.

$ git --version # git version 2.7.4 (Apple Git-66)
$ brew update
$ brew install git

Then modify your PATH on .bashrc or .zshrc, and put this line on the beginning of your path.

export PATH="/usr/local/bin:..another config..:"  # Separate each config with ":" colon

Last step what you need to do just restart your terminal.

$ source ~/.zshrc # I'm using ZSH
$ git --version   # git version 2.10.0

Reference: http://michaelcrump.net/step-by-step-how-to-update-git/

Git: Fix warning: unable to access ‘/.config/git/ignore’: Permission denied

I just cloned my repository from my github on my local machine and I don’t know why I got this error when trying to see my project changes using “git status”.

warning: unable to access '/Users/my_user/.config/git/ignore': Permission denied
On branch dev
Your branch is up-to-date with 'origin/dev'.
nothing to commit, working directory clean

After I check the folder, I just know that the folder owned by “root” user.

$ ls -lah
drwx------   3 root           staff   102B Aug  1 21:26 .config

I fixed my issue by changing the owner to my user on my laptop.

$ sudo chown my_user .config

Undo Last Published Commit in GIT

Today I’m refactoring my old code in my project and unexpectedly my refactor code messed up my apps. So I have to go back to my previous commit.

I know we can simply use.

$ git reset --hard your_commit_hash

But I couldn’t use that, because my previous commit already pushed to my repository.
Here is how to fix that using revert.

$ git log --oneline -5

a8031a3 Refactor tab host to swipable tabs for history
32d5856 Polishing order history progress # I need to go back here
3a984b0 Remove obsolete order handler
2b09868 Init order history
8102df9 Create order history pojo

$ git revert a8031a3 # commit hash that you need to remove.

Then it will remove my refactor commit and create new commit for revert.

c0cd60f Revert "Refactor tab host to swipable tabs for history" # new commit
a8031a3 Refactor tab host to swipable tabs for history
32d5856 Polishing order history progress
3a984b0 Remove obsolete order handler
2b09868 Init order history

Last step, what you need todo just push your commit. 😀

Thanks to Rezha 😀

Fix Git “Agent admitted failure to sign”

Don’t know why I got this error when I pull from my project, after added a new ssh key on my github account.

Agent admitted failure to sign using the key.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

To solve that error follow this step, enter on your terminal.

$ eval "$(ssh-agent -s)"
$ ssh-add
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/my_other_key

Reference: https://help.github.com/articles/error-agent-admitted-failure-to-sign/