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

Navigating branches and syncing #18

Merged
merged 11 commits into from
Jan 6, 2025
Merged
Binary file added git-refresher/images/pycharm_commit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git-refresher/images/pycharm_commit_msg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git-refresher/images/pycharm_push1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git-refresher/images/pycharm_push1_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git-refresher/images/pycharm_push2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git-refresher/images/pycharm_switch_branch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git-refresher/images/r_commit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git-refresher/images/r_commit_msg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git-refresher/images/r_push_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git-refresher/images/r_push_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git-refresher/images/r_switch_branch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 45 additions & 2 deletions git-refresher/moving-between-branches.qmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,61 @@
---
---
title: "Moving between branches"
---

...
This section will guide you through switching branches in your repo.

rmbielby marked this conversation as resolved.
Show resolved Hide resolved
Switching branches is useful for when we might need to pause our work on one branch and continue working on an issue in another branch. Before you switch branches it is important to commit and push the changes in the branch you're currently in. It's also important to pull changes after you switch to your new branch.

rmbielby marked this conversation as resolved.
Show resolved Hide resolved
::: panel-tabset
## Git Bash

First you need to update your local repo with the changes made to the remote one. This ensures that you have a full list of remote branches and the latest changes in the code to avoid conflicts. Enter the command below:

`git pull <github_id>_main`

In Git bash, you can switch branches using one of `git check out` or `git switch` followed by the name of the branch you want to switch to so choose either of the following options to enter:

`git checkout <github_id>_main`

OR

`git switch <github_id>_main`

## GitHub Desktop

## VS Code

## RStudio

- Go to the right hand side of RStudio and click on the Git tab.

- Click on the downwards arrow to "pull" the latest changes from the remote repo. This ensures that:

- you have a full list of remote branches.
- you have the latest changes in the code to avoid conflicts.

- Click on the drop down menu of branches. Usually "main" is the default branch shown before switching.

- Click on `<github_id>_main`

rmbielby marked this conversation as resolved.
Show resolved Hide resolved
- The example in the screenshot below show a branch name specific to another user. You need to click on your own branch.

![](images/r_switch_branch.png){fig-alt="The Git panel in RStudio with red rectangles highlighting the downwards pull arrow, the branches drop down menu and an example of a branch we want to switch to."}

## PyCharm

- Click on the branches drop down menu at the top of the screen.

- Click the Fetch icon to "pull" the latest changes from the remote repo. This ensures that:

- you have a full list of remote branches.
- you have the latest changes in the code to avoid conflicts.

- Click on "Remote" to see the full list of remote branches if you can't already.

- Click on `<github_id>_main` and then click "Checkout".

rmbielby marked this conversation as resolved.
Show resolved Hide resolved
- The example in the screenshot below show a branch name specific to another user. You need to click on your own branch.

![](images/pycharm_switch_branch.png){fig-alt="Highlighting PyCharm's branches dropdown menu, the Remote drop down sub menu, branch names and the Checkout option."}
:::
64 changes: 62 additions & 2 deletions git-refresher/recording-changes.qmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,78 @@
---
---
title: "Recording changes"
---

...
This section will guide you through recording changes you make to your repo.

These steps help you manage and track changes in your project, making collaboration and version control efficient and reliable.

Having [created your own branch](making-a-branch.html), follow the instructions below to make and record changes in your repo.

::: callout-tip
## Edit your git-academy-log file

- Put an x inside the brackets for the "Clone git-academy-sandbox" and "Create a new branch in GitHub (\<github_id\>\_main)".

- Save the file.
:::

::: panel-tabset
## Git Bash

- Check which files have changed by entering this command in Git Bash:

`git status`

- Stage the changes you want to commit by using one of the commands below.

- To add changes to one file at a time:

`git add <filename>`

rmbielby marked this conversation as resolved.
Show resolved Hide resolved
OR

- To add all changes:

`git add .`

- Commit changes with a message by entering:

`git commit -m "Checked clone sandbox and make new branch tasks"`

## GitHub Desktop

## VS Code

## RStudio

- In the Git panel of RStudio (see image below), tick the files you want to record the changes for.
- Click the commit button. It has a tick mark on two sheets of paper.

![](images/r_commit.png){fig-alt="Higlighting the Commit button and an example of ticking changes in the Git panel in RStudio."}

- Write a short message to describe the changes you made.

- Click "Commit".

![](images/r_commit_msg.png){fig-alt="Highlighting the commit message section and the Commit button in the RStudio: Review Changes pop up window that appears after completeing the last step."}

Note that you can see the changes made by comparing the green (current version) and the red (old version) highlighted sections.

## PyCharm

- Click on the branches drop down menu at the top of the screen and click "Commit".

OR

- Click on the symbol shown in the image below in the sidebar.

![](images/pycharm_commit.png){fig-alt="Highlighting the two ways to open the commit window." width="461"}

- In the "Commit" pop up window, tick the files you wish to record changes for if they're not already ticked.

- Write a short message to describe the changes you made.

- Click "Commit".

![](images/pycharm_commit_msg.png){fig-alt="Highlighting the commit message section and the Commit button in the Commit pop up window that appears after completeing the last step."}
:::
41 changes: 39 additions & 2 deletions git-refresher/syncing-changes-to-remote.qmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,55 @@
---
---
title: "Syncing to the remote"
---

...
This section will guide you through syncing your local repo to the remote one.

Any change made so far is only being applied to the local copy of the repository (i.e. the copy on your laptop). To apply your changes to the remote repository (i.e. on GitHub or Dev Ops), you need to “push” the changes.

rmbielby marked this conversation as resolved.
Show resolved Hide resolved
Having [recorded your changes](recording-changes.html), follow the instructions below to sync to the remote.

::: panel-tabset
## Git Bash

The first time you update your remote repo with the changes you committed to your local one (aka push the changes), use the command below:

`git push --set-upstream <github_id>_main`

rmbielby marked this conversation as resolved.
Show resolved Hide resolved
If you want to push changes you committed after that, use the following command:

`git push`

## GitHub Desktop

## VS Code

## RStudio

Click the green upwards arrow to push your changes to the remote repo. You can do this from the commit window as shown in the image below.

![](images/r_push_1.png){fig-alt="Highlighting the upwards arrow for pushing changes to remote repos in the RStudio's Review Changes window."}

### Alternative method

You can also do this from the side panel after closing the commit window as shown in the image below.

![](images/r_push_2.png){fig-alt="Highlighting the upwards arrow for pushing changes to remote repos in RStudio's Git window. It is there to show an alternative way of pushing changes to remote repos."}

## PyCharm

- Click on the branches drop down menu at the top of the screen and click "Push".

- A screen will pop up with your previous committed changes.

- Click "Push".

![](images/pycharm_push1_1.png){fig-alt="Highlighting the Push option in the branch drop down menu."}

![](images/pycharm_push1_2.png){fig-alt="Highlighting the Push button in the Push Commits to git-academy-sandbox pop up window that appears after completeing the previous step."}

### Alternative method

Alternatively you can push and commit your changes at the same time from the commit window by clicking "Commit and Push" after you write your commit message.

![](images/pycharm_push2.png){fig-alt="Highlighting the Commit and Push button in the Commit pop up window that appears after following the steps in recoding changes part of this guide."}
:::
Loading