Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git Branches section edits #476

Merged
merged 10 commits into from
Jun 7, 2024
28 changes: 17 additions & 11 deletions foundations/github/git-branches.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ Before we push this branch upstream, let's make some sample changes (like C3 or
touch hello.py
```

```{admonition} Note
:class: info
`touch` is not a Windows native command. You can use `type nul > file-name.py` to create an empty file instead.
anacmontoya marked this conversation as resolved.
Show resolved Hide resolved
```

![Git Status](../../images/6-samplechange.png)

You can check that this file has been created by comparing an `ls` before and after this command, and also with a `git status` that will show your new untracked file.
Expand Down Expand Up @@ -182,7 +187,7 @@ Thankfully, Git provided this command in the previous error message. If you clon

We can see that this worked by doing a `git branch -a`

Notice the new branch called `remotes/origin/newbranch`. And when you do a `git status` you'll see that we are up to date with this new remote branch.
Notice the new branch called `remotes/origin/branchA`. And when you do a `git status` you'll see that we are up to date with this new remote branch.
anacmontoya marked this conversation as resolved.
Show resolved Hide resolved

![Git Commit Status](../../images/7-github-branchandstatus.png)

Expand Down Expand Up @@ -269,22 +274,23 @@ git pull

`git pull` is a combination of `git fetch` and `git merge`. That is it updates the remote tracking branches (`git fetch`) AND updates your current branch with any new commits on the remote tracking branch (`git merge`).

This same concept appplies to work in a team setting. Multiple authors will have their own feature branches that merge into the same Upstream Main repository via Pull Requests. It is important for each author to do regular `git pulls` to stay up to date with each other's contributions.
This same concept applies to work in a team setting. Multiple authors will have their own feature branches that merge into the same Upstream Main repository via Pull Requests. It is important for each author to do regular `git pulls` to stay up to date with each other's contributions.

## Complete Workflow

All in all your Git Branching workflow should resemble this flow:
![gitworkflow](../../images/gitworkflow.gif)

1. Forking the upstream repository
1. Creating a local clone of your upstream fork
1. Creating a new branch
1. Switching branches
1. Making a commit
1. Setting up a remote branch
1. Merging branches via a PR
1. Deleting branches
1. Pulling from upstream
1. Fork the upstream repository
1. Create a local clone of your upstream fork
1. Create and switch to a new branch in local copy
1. Make changes
1. Add and commit changes in branch
1. Push commits to fork (Set an upstream branch only for first push)
1. Repeat last three steps as necessary
1. Merge via Pull Request
anacmontoya marked this conversation as resolved.
Show resolved Hide resolved
1. Delete branch from clone and fork
1. Pull upstream changes to fork and clone
anacmontoya marked this conversation as resolved.
Show resolved Hide resolved

---

Expand Down
Loading