<<
Home , Git

Git Commands

Common git commands ​ ​ Command Description Comments

git init Creates a new git repository in Not necessary when creating in the directory given. or GitHub. git clone Creates a local copy of the repo The command to clone from given in the directory. BitBucket or GitHub is located on their websites. git add Instructs git to start tracking the It is not necessary to add file(s) listed. directories, they are added when a file contained within is added. git Creates a checkpoint for all The second version stores changes git commit -a -m tracked files. to all tracked files and tags the “” commit with a message.

If the -m flag is not used, git will open a text editor to enter your message. -O will write the file and -X will exit the editor. git push Sends all commits to the main You must have one or more repository (server). commits in order to push. git pull Gets all commits from the main Notification is given if your repo is repository (server). up to date. git rm Remove the file from tracking and delete it. git mv Move the given file or directory to The tracked files are automatically another location. added. git reset --hard Removes all local changes since the last commit. git status Lists all changes since the last commit git revert Undo changes of one or more See online documentation for commits. details. More details for these commands (and others) are at: https://git-scm.com/docs/ ​

This workforce product was funded by a grant awarded by the U.S. Department of Labor’s Employment and Training Administration. The product was created by the grantee and does not necessarily reflect the official position of the U.S. Department of Labor. The U.S. Department of Labor makes no guarantees, warranties, or assurances of any kind, express or implied, with respect to such information, including any information on linked sites and including, but not limited to accuracy of the information or its completeness, timeliness, usefulness, adequacy, continued availability, or ownership.