Making a new branch
In a Git repository, different versions of work are controlled by using what are called “branches”. Edits can be made to files on a branch and those will not effect files on any other branch.
Most repositories will have a “main” branch. This is considered the central latest working version of your work. When editing work, we generally don’t make edits directly on the main branch. Instead we create specific branches for specific chunks of work.
Having cloned the git-academy-sandbox repository, now make a new branch to work in.
Replace <github_id>
in the below with your GitHub username to make your own personal main branch in the sandbox repository.
git checkout -b <github_id>_main
Click Branch in the menu bar and then select New branch… as shown in the screenshot below.
Then enter your branch name as <github_id>_main
(but replacing jsmith_main
)
The current branch (main) should be listed in the very bottom left hand corner of the VS Code window frame. If you left click on this, you should then see a menu appear at the top of the VS Code window with some branch options (as shown in the screen shot below).
Click + Create new branch… and then enter your branch name as <github_id>_main
(but replacing jsmith_main
).
You should now see the branch name listed in the bottom left of the window frame shown as the branch you just created, meaning any changes you currently make will be applied to that new branch (and not main).
In the Git panel, click the purple new branch symbol as circled in the screenshot below.
Then enter your branch name as <github_id>_main
(but replacing jsmith_main
)
Open up the Git panel in PyCharm and you should see something like the screenshot below. Right click on main and select New branch from ‘origin/main’….
Then enter your branch name as <github_id>_main
(but replacing jsmith_main
).