(@encima)[https://github.com/encima]
git init
- Creates a git repository locally on your machine. (this is basically a
.git
folder with config and other things inside)
- Creates a git repository locally on your machine. (this is basically a
git remote add origin <link>
- Addss the link of the remote repository (github, gitlab) etc as the origin alias
git add .
- This adds all the things in your directory to the repository
git commit -m 'initial commit'
- Commits should happen after changes have been made to a file or files
git pull origin master
- Pull any other changes down from the remote repository (crucial if you are working with other people)
git push origin <branch>
- Push your commit changes up to the remote repository
- Repository - The directory containing your code
- Remote repository (often called
origin
) - The link to where your repository is stored online - Commit - A checkpoint in your development that signifies a change (i.e. a bugfix or implementing a login page)
- Pull - Check for changes in the remote repository and download them to your machine
- Push - Upload your changes to the remote repository
- Branch - Contains different versions of code. Default is the
master
branch but this can be anything - Merge - Happens when there are conflicts between your code and the remote repository (or vice versa), you must merge your changes and then commit again (git will often try and auto merge)
git checkout -b <branch>
- Creates a new branch and switches to it.
git branch <branch>
- Create a branch but do not switch to it.
git branch
- List all branches
git branch -d <branch>
- Delete local branch
git merge <branch>
- Merge the named branch into the current branch you have checked out
git reset --hard HEAD
- If you totally mess up, this will revert your local repo to the last committed state
git stash
- Stash your changes but do not commit them
git stash apply
- Apply the stashed changes
git log
- A log of all commits and by whom they were made
git tag
- Tag a point for easy access later (i.e. Versions)