Getting Started with Git

A Simple Workflow

Version 1

  1. Initialize: Use git init workspace to create the initial workspace and some initial Git configuration files.

  2. Configure: If this is your first time using Git, you can configure basic information with git config:

    git config --global user.name userName

    git config --gaobal user.email userEmail

    Note that --global applies to all repositories for the current user, --local applies only to the current repository, and --system applies to every user on the current machine.

  3. Edit and commit: Work on your files. When you want to save a checkpoint, use git add fileName to stage the current file, then git commit -m "someMessage" to commit everything in the staging area to the commit tree.

Version 2

  1. Initialize: Use git clone url to download an existing repository.
  2. Configure: As above. You can also edit “.gitignore” to avoid tracking intermediate files.
  3. 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, use git remote add origin url to add its address, then git push origin master to push to it.