I use Git and Github a lot these days. It's cool and all but there were the inevitable hickups along the way. Lots of Googling. Here's a list of things that I wish had been all in one place when I started. I provide this for others(my future self included) who might be new to Git/GIthub and want to lessen the learning curve a bit. These tweaks assume you already have Git installed, a free Github account and an SSH key. If not, create an account at Github and follow these steps to create an SSH key. Moving on...
These are the problems I ran into early on and how they got fixed plus a few tweaks.
- Every time I do a git push to a repo on Github, I get asked for username and password.
- This is most likely because you did a git clone from HTTPS and not SSH. I'd post a screen shot but the UI will probably change at some point. Look on the github repo page, find the clone URL and make sure that you are copying the one for SSH. More info.
- I make changes on my local branch, but when I push to Github it says, "Everything is up to date" even though it's not.
- Instead of doing
git push
, dogit push origin <branch name>
, likegit push origin newfeature
. More info. - I get asked for a pass phrase every time I do a push or pull. More info.
- On the command line type:
- eval $(ssh-agent) <enter>
- ssh-add <enter>
- Helpful git aliases
- You can run this at the command line to make typing git commands a little easier.
$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status
git commit
becomesgit ci
.git checkout
becomesgit co
andgit branch
becomesgit br.
(These aliases were taken from Scott Charon's book Pro Git)- Color!
- It's nice to have some color on the command line. Set this so that the git diff, git status and other commands return some color variation to make things easier to read.
$ git config --global color.ui true
- More Info
- Lastly, instead of doing
git commit -m 'message'
all the time, you can do agit commit -av
which will launch the default text editor, let you view the changes that are going into the commit AND type the commit message. I like using Sublime, so updated the git config to do so. - git config --global core.editor "subl -n -w"(More Info)
If you see anything wrong, let me know. Present and future me thanks you, but not past me. Past me is a corner cutting jerk.
No comments:
Post a Comment