To install on Ubuntu
- Type: sudo apt-get install git
Create a working directory and add files in there
- Type: mkdir .... (replace "..." with the working directory)
Initilize Git into the working directory
Configure Git username and email to track who makes the changes in a project
- Type: git config --global user.name "David Mahler" (sets the name)
- -global means that those credentials will be used for every other repository installed on the system, to avoid having to do this again on every repository.
- -local should be used if you wish to use different credentials for a particular repository on the system.
- Type: git config --global user.email "dave@some-email" (sets the email)
- Type: git config --list (shows if name and email is set)
Add a file to the staging area
- Type: git add ... (gets the file into the staging area for tracking)
- Type: git add . (the dot means to add new and modified files to the staging area)
Make a Git commit
- Type: git commit -m "..." (creates a "named" commit with whatever is in the staging area and m omits the need for a comment)
- Type: git commit -a -m "...." (to both stage and commit tracked files that have been modified)
- Type: git commit (creates a commit and takes you to the default file editor to enter notes about the changes)
Remove a file
- Type: git rm ... (removes a file from the staging area and also the working tree. This is better than just typing rm because it needs to be followed with git add ... )
- Type: git rm --cached ... (removes a file from the staging area on the next commit)