Getting Started with Git
Contents
A Simple Workflow
Version 1
-
Initialize: Use
git init workspaceto create the initial workspace and some initial Git configuration files. -
Configure: If this is your first time using Git, you can configure basic information with
git config:git config --global user.name userNamegit config --gaobal user.email userEmailNote that
--globalapplies to all repositories for the current user,--localapplies only to the current repository, and--systemapplies to every user on the current machine. -
Edit and commit: Work on your files. When you want to save a checkpoint, use
git add fileNameto stage the current file, thengit commit -m "someMessage"to commit everything in the staging area to the commit tree.
Version 2
- Initialize: Use
git clone urlto download an existing repository. - Configure: As above. You can also edit “.gitignore” to avoid tracking intermediate files.
- Edit and commit: After editing and saving, if you want to commit all tracked files in the working area directly to the commit tree, run
git commit -a -m "someMessage"to skip the git add step. Finally, to push to a remote repository, usegit remote add origin urlto add its address, thengit push origin masterto push to it.