|
5 | 5 | * Replace the `<new-branch-name>` items below with your appropriate formed `<studentdirectoryname-labnumber-lab-name>` branch name.
|
6 | 6 | * An example `<new-branch-name>` would be `bruce-lab01-python-exercise`
|
7 | 7 |
|
| 8 | +1. It's good practice to get the current git status to see what branch is current, what files have been changed, and other details: |
| 9 | + `git status` |
| 10 | + |
| 11 | +1. Reminder, git branch can be used to see our current branch and other available local branches: |
| 12 | + `git branch` |
| 13 | + |
8 | 14 | 1. Checkout the `main` branch since we want to keep it syncronized with remote:
|
9 | 15 | `git checkout main`
|
| 16 | + |
10 | 17 | 1. Retrieve the remote changes to `main` branch and sync them to local repository:
|
11 | 18 | `git pull origin main`
|
| 19 | + |
12 | 20 | 1. Create a new branch `<new-branch-name>` from current state of `main` branch:
|
13 | 21 | `git checkout -b <new-branch-name>`
|
| 22 | + |
14 | 23 | 1. Do some code changes.
|
| 24 | + |
15 | 25 | 1. Add all the changes made to git tracking (or add only `<filename>` or `<directoryname>` changes):
|
16 | 26 | `git add -A`
|
| 27 | + |
17 | 28 | 1. Commit the changes made to the branch:
|
18 | 29 | `git commit -m <commit message>`
|
| 30 | + |
19 | 31 | 1. Push local changes to branch `<new-branch-name>` to the remote repository `origin`:
|
20 | 32 | `git push origin <new-branch-name>`
|
| 33 | + |
21 | 34 | 1. Do some more code changes.
|
| 35 | + |
22 | 36 | 1. Add all the changes made to git tracking:
|
23 | 37 | `git add -A`
|
| 38 | + |
24 | 39 | 1. Commit the changes made to the branch:
|
25 | 40 | `git commit -m <commit message>`
|
| 41 | + |
26 | 42 | 1. Push local changes to branch `<new-branch-name>` to the remote repository `origin`:
|
27 | 43 | `git push origin <new-branch-name>`
|
| 44 | + |
28 | 45 | 1. When lab is completed, [create pull request on GitHub](10%20GitHub%20Pull%20Request.md).
|
| 46 | + |
29 | 47 | 1. After lab has been graded and pull request approved, perform the following two commands to remove the reference to the remote branch, and then delete your local branch:
|
30 | 48 | 1. `git remote update origin --prune`
|
31 | 49 | 1. `git branch -d <graded-and-merged-branch-name>`
|
|
37 | 55 | 1. Git `add` and `commit` changes to current branch:
|
38 | 56 | 1. `git add -A`
|
39 | 57 | 1. `git commit -m <commit message>`
|
| 58 | + |
40 | 59 | 1. Checkout the different branch we want to work on:
|
41 | 60 | * `git checkout <a-branch-name>`
|
| 61 | + |
42 | 62 | 1. Do the code changes for this branch.
|
| 63 | + |
43 | 64 | 1. Git `add` and `commit` changes to the new current branch `<a-branch-name>`:
|
44 | 65 | 1. `git add -A`
|
45 | 66 | 1. `git commit -m <commit message>`
|
| 67 | + |
46 | 68 | 1. Checkout some other branch we want to work on:
|
47 | 69 | * `git checkout <some-other-branch-name>`
|
| 70 | + |
48 | 71 | 1. Repeat process as needed.
|
49 | 72 |
|
50 | 73 | ## Use the following to delete branches for labs which have already been graded.
|
51 | 74 | * NOTE: We delete the branches after they have been merged into `main` since the work has been completed and all the changes have been recorded in the `commit`s. We no longer need the branches.
|
52 | 75 |
|
53 | 76 | 1. Sync our local record of remote branches. This will remove local references to branches which have been deleted on remote:
|
54 | 77 | * `git remote update origin --prune`
|
| 78 | + |
55 | 79 | 1. Delete the local copy of the branch:
|
56 | 80 | * `git branch -d <lab-branch-which-has-been-graded>`
|
0 commit comments