Common commands for working with git
Download repository to local
git clone
Checkout a branch
git checkout [branch name]
Create a new branch
git checkout -b [branch name]
Get a list of branches in this repository
git branch
Get new changes from remote
git pull
Add new files to repository
git add [filename]
Commit all changes to the repository
git commit -am "Message describing the committed code"
Commit single file to the repository
git commit path/to/file -m "Message describing the committed code"
Push your changes to remote
git push
Git configuration
Add global username to your git configuration
git config --global user.name "Your Name"
Add global email to your git configuration
git config --global user.email "[email protected]"
Ignore files globally
Create .gitignore_global in your home folder.
Run this:
echo .DS_Store >> ~/.gitignore_global
to create .gitignore_global file in your home folder and exclude all .DS_Store files.
Then run:
git config --global core.excludesfile ~/.gitignore_global
for git to use it for all repositories.
You need to run this everytime you update .gitignore_global