84.3 Git Developer Workflow Pre Coding

20210113 Also see Section 84.32 and following for other workflow suggestions.

1. Clone a Repository

A generic git workflow for a team, with developers working on specific tasks/tickets/issues, begins with a clone of the repository. The URI identifies the repository (e.g., git@github.com:...) and can be obtained from the Code button of the github repository through the browser. The command to clone is:

$ git clone git@github.com:<owner>/<repo>.git

2. Create a Branch

For a specific task create a branch, generally from the main branch, to encapsulate the work. For a task to add a feature to validate user input, the branch might be called validator.

We begin by ensuring the main branch is the default:

$ git checkout main

Next, download to the local copy any changes that have been made to the main branch in the remote repository.

$ git pull --rebase
$ git branch validator                      # Create a new branch named validator.
$ git checkout validator                    # Make this branch the default.
$ git push --set-upstream origin validator  # Notify the upstream repo of this branch.

A shortcut to create and check out a branch is to add -b to the checkout command.

$ git checkout -b validator                 # Create new branch and check it out.

3. Coding

Undertake the activity on that branch locally and commit (to share your work) regularly to the branch. Test the branch in the development environment for your deployment.

Your donation will support ongoing development and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.