Wiki

Clone wiki

pflotran / Developers / CodeDevelopment / IntroToGit

Getting started with Git

  • In particular, set up your global identity.
  • Starting and working on a new feature branch (based loosely on PETSc's approach)
  • Make sure you start from master: git checkout master

  • NEVER create a branch from next

  • Create and switch to a new feature branch (most likely from master, an existing feature branch, or from maint if a bug fix):

    git checkout -b <name>/<affected-package>-<short-description>
    

    For example, Glenn's new feature branch forcing a two-phase state in general mode.

    git checkout -b glenn/general-force-two-phase-state
    

    Use all lowercase and no underscores.

  • Write code

  • Inspect changes: git status

  • Commit code (Be very careful here not to add untracked files that you do not intend to add):

  • Add new files to be committed: git add file1 file2 followed by git commit. Modified files can be added to a commit in the same way.
  • Add all modified tracked files: git add -u . followed by git commit,
  • Commit all files changed: git commit -a (Careful, this will add everything tracked/untracked!), or
  • Commit selected files: git commit file1 file2 file1
  • Push feature branch to the remote for review: git push -u origin glenn/general-force-two-phase-state (or equivalently, git push --set-upstream origin glenn/general-force-two-phase-state)

Updated