-
Notifications
You must be signed in to change notification settings - Fork 1
Home
git init
Initializes an empty Git repository - use this if you want to create a brand new repo. See git-clone
if you want to clone from an existing one (you cannot use Git commands unless you have a .git repository.)
git clone
Creates a local clone of a Git repository, such as the repo hosted here on Github or one from a friend's computer - you should only have to do this once. Clone creates an exact copy of the repo, including branches, commits, etc.
git add
Adds indicated files to the Git staging area. You can use git add .
to add all files.
git commit
Creates a commit from all the new and changed files currently in the staging area. Commits are the fundamental unit of Git versioning - each branch, including master, can be thought of as a series of sequential commits. This will prompt you for a commit message, but you can use git commit -m <message string>
to include a message right in the command.
git status
Shows a report of all files (staged in green and unstaged in red) that have been modified since the last commit.
git checkout <branch-name>
Changes your working branch. When you change branches, your entire project folder is switched with the version that is reflected by the commits in the branch - this includes any changes in files, and every file that has been added or removed will be added or removed from the working directory.
git checkout –b <working-branch>
Creates a new branch on your local machine. It is a good idea to use local branches when adding specific features or changes. This way if you do not like what you have done you can easily get rid of the work.
git branch
Shows existing local branches and tells you the branch in which you are currently working.
git branch -D <branch-name>
Deletes an existing local branch. You need to be in a local branch other than the one you are deleting in order to delete .
git pull
Retrieves information from an upstream Git repository and places it in your local Git repository. You use this command to make sure you are synchronized with the repository from which you are basing changes (such as the master branch).
git push
Sends all your committed local changes to an upstream Git repository (e.g. a contribution repository). The maintainer of the project draws from these repositories when adding changes to the project’s master repository or other development branch.
git merge
Combines or adds changes from one local branch of your repository with another branch. When you create a local Git repository, the default branch is named "master". A typical workflow is to create a temporary branch for isolated work, make and commit your changes, switch to your local master branch, merge the changes from the temporary branch into the local master branch, and then delete the temporary branch.
git cherry-pick
Choose and apply specific commits from one branch into another branch. There are times when you might not be able to merge all the changes in one branch with another but need to pick out certain ones.
gitk
Provides a GUI view of the branches and changes in your local Git repository. This command is a good way to graphically see where things have diverged in your local repository.
git log
Reports a commit history of the current repository.
git diff
Displays line-by-line differences between your local working files and the same files in the upstream Git repository that your branch currently tracks.