Common Git Commands

You are here:
< Back

git clone
This command clones a repository into a new directory, creates remote-tracking branches, and forks a new working branch from the cloned repository’s active branch.
git clone repositoryurl
In the example above, repositoryurl represents the URL of the repository that you wish to clone.

git add

This command adds the current version of a file to the index of staged content for the next commit.

git add [options] filepath

In the example above, filepath represents the file’s absolute path or its path relative to the current working directory.

  • To stage uncommitted changes for all tracked files, run this command with either of the -a or -u options (and without a specified file path).
  • This command only stages the current changes for the current commit. The next time that you create a commit, you must run the command for the file again in order to stage any new changes.

git commit

This command creates a new commit for the currently-staged changes.

git commit [options]

When you run this command (without the -m option), Git immediately displays a text file, in which you can enter and save your commit message.

  • To automatically stage modified and deleted files before Git creates the commit, run this command with the -a option.
  • To specify a short commit message directly from the command line, run this command with the -m option. For example:
    git commit -m "Commit message here."
Last Updated On July 31, 2018

Leave a Reply

Your email address will not be published.