The team's sandbox repo for practicing Git stuff.
- Set your username in Git (N.B. this is not your GitHub username) following these directions.
- Set your email address in Git and GitHub following these directions.
git config --global user.email "[email protected]"
- Check it with
git config --global user.email
- Set your GitHub credentials:
- If you want to clone with HTTPS, cache your GitHub credentials in Git.
- If you want to clone with SSH, you'll need to first generate the SSH key, then you'll have to add the key to your GitHub account.
- [Optional] Add VS Code to your PATH and set your default Git editor to VS Code with
git config --global core.editor "code --wait"
.
- Clone the repo using
git clone [email protected]:Digital-HR/git-practice.git
if you set up an SSH key in the configuration steps above, or usinggit clone https://github.com/Digital-HR/git-practice.git
if you cached your GitHub credentials instead. cd git-practice
. All subsequent Git commands should be done whilegit-practice
is your current directory.
We use Gitflow for organizing our work. Note that our branch names are slightly different, though - master
from the Atlassian tutorial is main
in our organization, and develop
is dev
.
- Assign yourself to the feature ticket.
- Ensure you're checked out to the
dev
branch locally by runninggit branch
. You should see a list of branches with a star (*) next todev
, indicating that you're checked out to it. - Pull in the latest changes from
dev
withgit pull origin dev
. - Create a branch to fix the issue and check out to it.
- Use the issue number in the branch name:
git checkout -b issue-1
- Optionally include a description of the change in the branch name. It's sometimes difficult to anticipate what the change will be before you make it, so don't stress too much, but the issue title could be used if you think it provides enough detail:
git checkout -b issue-1-add-interesting-text
- DO NOT use branch title like
fix-function1
. It's not descriptive enough, doesn't tie it to an issue, and is very vague. - Johanan's preference is to use context, his initials and the issue number:
git checkout -b feat/ji/issue-1
.
- Use the issue number in the branch name:
- Make your changes in that branch.
- Stage your changes.
- If you want to include all your changes in a specific file in your commit:
git add Main.py
. - If you instead wish to stage only hunks of your changes in a file, use the
-p
flag:git add -p Main.py
- If you want to include all your changes in a specific file in your commit:
- Check that your staged changes are the ones you intend to commit:
git diff --cached
. - Commit your changes with
git commit
. Remember to write an informative commit message. - Push your changes to remote with
git push
. - Submit a pull request from your branch to
dev
(the trunk branch). - Once your PR has been approved, merge your branch into
dev
. - Locally checkout to
dev
withgit checkout dev
(note the-b
flag is not needed since the branch already exists). - Pull the latest changes from origin with
git pull
. - Delete your local feature branch with
git branch -d feat/ji/issue-1
.
- Assign yourself to the hotfix ticket.
- Ensure you're checked out to the
main
branch locally by runninggit branch
. You should see a list of branches with a star (*) next tomain
, indicating that you're checked out to it. - Pull in the latest changes from
main
withgit pull origin main
. - Create a branch to fix the issue and check out to it. Use the new version number in the branch name:
git checkout -b hotfix/v1.0.1
. The last digit of the tag is incremented for hotfixes. - Make your changes in that branch.
- Stage your changes.
- If you want to include all your changes in a specific file in your commit:
git add Main.py
. - If you instead wish to stage only hunks of your changes in a file, use the
-p
flag:git add -p Main.py
- If you want to include all your changes in a specific file in your commit:
- Check that your staged changes are the ones you intend to commit:
git diff --cached
. - Commit your changes with
git commit
. Remember to write an informative commit message. - Push your changes to remote with
git push
. - Submit a pull request from your branch to
main
. - Once your PRs have been approved, merge your branch into
main
anddev
. Do not delete the hotfix branch! - Review and merge the autogenerated PR into
dev
that you're tagged on.
- Click the "Run workflow" button for the release-candidate workflow. Use the workflow from
dev
. The version number should be in the formX.Y.Z
where X corresponds to the MAJOR version, Y corresponds to the MINOR version, and Z corresponds to the PATH version. See https://semver.org for more details on how these values should be incremented. - Review the pull request you're tagged on.
- Merge the PR.
- Review and merge the PR into
dev
that you're tagged on.