Basic Git Commands
My knowledge of Git is very limited. In fact, I thought I messed up my computer forever trying to install a newer version of Git to use on my Mac. It was a mess, and now I'm back to using the old one Apple gave me.
That's mostly unimportant here, but honestly, if you know how to find and properly uninstall a bunch of versions of Git on a Mac, please write about it. Then send me the article.
Checking for Git
To make sure we have Git, run
git --version (which tells us our current version in use) and/or
which git (which tells us the location of our git install).
Don't ask me how to install it if those don't give results (or if it's outdated). I honestly couldn't tell you the best way. Apparently using Homebrew, but good luck to you if you encounter any errors trying that...
Creating a Git repository in Our project
In our main project folder, use
git init. We'll get an empty repository.
Some Basic Commands
git add file-name — adds that specific file to the staging area
git add -A — adds all modified files to the staging area
I believe this includes brand new files, but I need more experience to know for sure.
git status — gives you an overview of what's where (which files have been modified, which are in staging, which aren't tracked, etc)
git commit -m "This is the commit message. Try to always add one." — commits all files in the staging area to the repository
git commit -a -m "Message" — adds all modified files to the staging area and commits them, with a message
Working with Remote Repositories
git remote add origin https://github.com/username/repository.git — adds the remote repository to our local repository, giving it the 'origin' nickname
git push -u origin master — pushes our local master branch to the remote repository nicknamed 'origin', that we added earlier.
git push — can use after we've written it out in full at least once