Lately my sister has been working on her first php site. I wanted to tell her how to set up a git repo at BitBucket with ssh keys. Then, I realized a handful of other people have asked me about the same thing, and decided to make a blog post instead of an email. I know this is a bit scrappy, but it will at least get you started. Since this is geared at my sister, I'm assuming OS/X, but the instructions aren't too different on Linux.
Well, it's git and has free private repositories. Use any server you want.
I prefer using ssh authentication. There's no password typing.
...or whatever git server you want.
which git
brew install git
ssh-keygen
cat ~/.ssh/id_rsa.pub
git@bitbucket.org:user/repo.git
cd /path/to/my/repo # here, change the directory to match your project
git init . # initialize a local git repository
# these commands can be used repeatedly to commit new changes
git add path/to/files # add all the files that need to be in the repository
git status # use this command to see the state of your git repository
git commit -m "Commit message here"
# run these commands just once to set up the remote origin of the repository
git remote add origin git@bitbucket.org:user/repo.git # take this url from bitbucket
git push -u origin --all # pushes up the repo and its refs for the first time
git push -u origin --tags # pushes up any tags
If you're on OS/X, I recommend that you download the popular GUI utility, gitx, to view changes, logs, etc.
A file goes through various changes in git.
git status
So, for example. Let's say you make a change that you want me to have. So, first you add the file, then commit it, then push it. I pull it, fix a spelling error, add it, commit it, and push it. Now, when you pull from the server, you will receive the changes I pushed earlier!
As a rule of thumb, you should always pull before trying to push changes to the remote origin. Why? Because you don't know if someone else has already pushed changes. You'll have to figure out how to merge the changes in your local version of the repository, and only then can you push to remote.