Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Thursday, September 17, 2015

Committing code to both Heroku and Github

I found it a bit confusing that Heroku uses git, but whenever I entered git push heroku master, I wasn't updating my github repository...I was only updating the Heroku git location.

To make sure you update both locations correctly, from your master branch, enter

git remote -v
in the command line to see what other branches you currently have set up.

If you are in the midst of working on a Heroku deployment, but have also committed code to a Github repository in the past, you will get a list of both Heroku & Github links when you enter the command above (differentiated clearly in parentheses after each link).

This is useful if you want to double check that you have the correct Github repository set as "origin" before doing committing code by typing:
git push origin master

Hooray! 

Sunday, April 26, 2015

Frustration of the Week: How to Overwrite Apple Git (old version) with Homebrew Git (newer version)

So you've got two versions of Git on your Apple machine: the Apple-installed version and the Homebrew version. Unfortunately, the Apple version is outdated, and your computer won't stop using that one instead of your shiny new Homebrew version. You know because when you type git --version into the command line, you see the old version showing up instead of the new one. Rats!

Entering:
export PATH=/usr/local/bin:$PATH
and then
git --version
will temporarily get your console to show the updated version. But once you exit out of the Terminal and reopen the Terminal, your computer will go back to its old ways again.

That means that

which git
tells you

/usr/bin/git
instead of

/usr/local/bin/git
You want /usr/local/bin/git because that is where the newer version is installed.

Why, computer gods, why??

It's really quite simple. Your computer does not hate you. It's just following the instructions located in its .bash_profile.

To tell it what you want it to do, you need to edit your bash profile.

In Terminal, type the following commands:

cd
touch .bash_profile
open -a "TextEdit" .bash_profile
Your .bash_profile will open in TextEdit. Add this line to the file:
export PATH="/usr/local/bin:$PATH"
Save it and enter this in the Terminal to finalize the change:
source .bash_profile
Now you have to link your Homebrew git, by saying 
brew link git

Now (FINALLY), which git should say /usr/local/bin/git

...which is where Homebrew's updated git version should be located. Success!

Now every time you need to update your git, you just say:

brew update
brew upgrade git
That's it! Awesome.

A million thanks to the kind helpers who shared their wisdom via the following threads:
http://superuser.com/questions/409501/edit-bash-profile-in-os-x
http://superuser.com/questions/708601/homebrew-cant-link-git