Showing posts with label github. Show all posts
Showing posts with label github. Show all posts

Sunday, September 25, 2011

Github as the second remote

This is a brute-force way of setting up github as a second remote/backup to your code.

1. $ cp -r repo repo_backup
2. $ cd repo_backup and then vim .git/config
delete the old [remote "origin"]
3. $ git remote add origin git@github.com:username/repo_name. Now you should see its corresponding lines in .git/config
4. I want to push my local branch "b1" to a branch on github named "branch1", so I did git push -u origin b1:refs/heads/branch1

Friday, September 9, 2011

git edit commit message and push to github

Steps to edit a git commit message and also have it show up to Githb:

1. To edit your last commit message:

git commit --amend

2. Edit your commit message on top. If you're using vim, to save and quit, do esc+":wq"

3. Push to Github:

git push --force


Note that if you don't have the "--force", you'll get this error message:

$ git push
To git@github.com:your/repo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:your/repo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
So remember to git push --force!

Sunday, March 27, 2011

Can't push on Github

When I tried to git push new commits into github, it asks:

Enter password to unlock the private key
An application wants access to the private key
'[my email]' but it is locked.

I tried all my passwords but it didn't work. Google didn't help much either.

Victor is here to help:

It means you password-protected your SSH keys, despite all the advice
against doing so.

The easiest fix is to blow up and re-generate your keys.

cd ~/.ssh
rm id_*
ssh-keygen
# Do NOT enter a password; just press Enter every time it asks a question
cat id_rsa.pub
# Go to GitHub -> account settings -> ssh public keys -> add another public key

Now I can finally navigate to my project directory and do
git push