How to setup Coda 2 to push to GitHub?

Setting up a new site in Coda 2 and cloning a GitHub remote repository is not that big of a deal. Where you will most likely run into problems is when you try to push your changes to the GitHub remote repository. Below I will show you how to update the Git config file in your local repository so you do not run into one of the following errors:
  1. git push failed remote: Remote anonymous access to repository denied
  2. git push origin master Username: fatal: Could not read password
The GitHub repository address I am going to use is that of Source Code DNA: https://github.com/thetitan/sourcecodedna.git. I will assume that you have already setup your Coda 2 site profile and cloned your repository, you have made some changes, and now you are ready to push those changes to your projects GitHub repo.

git push failed remote: Remote anonymous access to repository denied


The first error message you will encounter on your first try to push. This is because the target URI is just an address, there is no account username in it to authenticate with. To resolve this we will prepend the GitHub account username. In my case it is thetitan. So the target URI will become https://thetitan@github.com/thetitan/sourcecodedna.git. Now Git has a username to authenticate with.
Git config file without site username.

This change will be made in the git config file of your local project directory. To edit the file execute the following command "vi ~/path to project directory/.git/config". Since the local repository directory is hidden you will have to do this in the terminal app. Remember to replace the "path to project directory" with your local directory hierarchy.
Site Git config file - username in URI.

git push origin master Username: fatal: Could not read password


The second error message is caused by the changes we made to the target URI when we added the username. Because the remote repository address was changed to include a login username there is no associated password with it in the keychain, anymore. To fix this we will have to update the Coda site SCM (source tab) configuration. All you have to do is select the remote repo from the drop down, the default name is "origin", and add your GitHub account password.
Coda SCM setup

Comments

  1. I did this but it keeps on going back to the "local" repository. I've done a couple of changes in my local repository... created a few more branches... but it is not syncing with the remote. When I go to the github site. I see the old repo.

    The github GUI that I installed on my osx is showing the changes that I've done on local repo and asking me to sync with the github site. If I do that, the both are synced. But I need it to get working through Coda ... any ideas?

    ReplyDelete
  2. Hello Nadir,

    What is your work process? Do you commit only, see image 1? Or do you also push, see image 2?

    If you first commit, then you push to your repo, this should update the remote repository from within Coda. Unlike other tools, e.g. SourceTree where it can update/push to the remote repository at the time of the commit, with Coda it is a two step process. A commit will only update your local repo.

    Coda Commit (image 1) - http://i1.wp.com/titanfusion.net/wp-content/uploads/2013/12/coda-commit.png
    Coda Push (image 2) - http://i1.wp.com/titanfusion.net/wp-content/uploads/2013/12/coda-push.png

    ReplyDelete
  3. Hey Alexandar,

    Thanks for your reply. I figured out that Coda doesn't sync new branches created through Coda itself with remote. As you've mentioned in your reply, we have to "push" to origin in order to sync with the remote (GitHub). That works perfectly, but only for those branches that we already have on GitHub. For new branches created with Coda through dropdown menu, we have to use terminal with;
    $ git push origin newBranch

    or we have to use the GitHub app for Mac to sync all the branches and commits.

    ReplyDelete
  4. I found a way to make the authentication change without touching the config file directly. http://www.earlymarket.com/2/post/2014/02/coda-2-and-github.html.

    ReplyDelete
  5. I am still a bit confused about whether I have too many steps. User A and B each have their local repositories and we use Github for the team repository. It seems like a lot of committing, pushing and pulling. Furthermore, when one user has a conflict, the git comments end up in their local version of the file. This means that they cannot publish it to FTP in Coda. Really, only the Github origin should be published to FTP?

    ReplyDelete
  6. You are a star mate!

    ReplyDelete
  7. Ha! So that's the trick! I was wondering why it always failed to find the username... Well done, it worked awesomely!

    ReplyDelete

Post a Comment

Popular posts from this blog

Format MAC Address [JavaScript]

SNOOZ: Sound. Sleep.

Balloon Flowers of 2014