Git is a version-control platform. It keep track of file/project changes, and controls changes from different contributors.
This blog only covers a summary of the commands. See full documentation here.
Command | Description |
---|---|
git init | initializes directory as a git repository |
git add [filename] | stages a file for the next commit |
git add . | stage all changed files for the next commit |
git restore [filename] | restore a file from staging |
git rm --cached [filename] | remove a file from staging |
git status | displays git status which includes the branch name you're working on, the list of changes, and stages ready for commit |
git commit -m "[message]" | commit changes with a message describing the changes made |
git checkout -b [branch name] | creates and shifts to a new branch simultaneously |
git checkout [branch name] | switch to an existing branch |
git config --global user.name=[username] | configures your local respository |
git config --global user.email=[email] | configures your local respository |
git remote add [reference] [github repo] | adds or reference a remote repository |
git push [reference] [branch name] | push all commits to the referenced remote repository of the specified branch name |
git push -u [reference] [branch name] | -u remembers the referenced remote repository and branch name, so that next time the command can be shorted to git push only |
git pull [reference] [branch name] | pulls from the referenced remote repository into your local branch |