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.
62 changes: 60 additions & 2 deletions git-refresher/moving-between-branches.qmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,76 @@
---
---
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

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.

### Step 1a: Check that you're in your repo's directory

`pwd`

### Step 1b: Navigate to repo's directory

If you're in the correct directory, skip this step. If you're not, navigate to your repo's directory by using the cd command.

`cd path/to/repo/`

### Step 2: Sync local repo with the remote one

This step is for updating your local repo with the changes made to the remote one. This ensures that:

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

`git pull origin <branch-name>`

### Step 3: Switch branches

`git checkout <github_username>_git-bash_stage_1`

OR

`git switch <github_username>_git-bash_stage_1`

## 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_username>_rstudio_stage_1`

- 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)

## 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 your branch and then click "Checkout".

![](images/pycharm_switch_branch.png)
:::
76 changes: 74 additions & 2 deletions git-refresher/recording-changes.qmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,90 @@
---
---
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 [cloned your repo](clone-a-repo.html), follow the instructions below to make and record changes in your repo.
rmbielby marked this conversation as resolved.
Show resolved Hide resolved

### Step 1: Make a change to your git-academy-log file
rmbielby marked this conversation as resolved.
Show resolved Hide resolved

- Put an x inside the brackets for the "Clone git-academy-sandbox".

- Save the file.

::: panel-tabset
## Git Bash

### Step 2a: Check that you're in your repo's directory
rmbielby marked this conversation as resolved.
Show resolved Hide resolved

`pwd`

### Step 2b: Navigate to repo's directory

If you're in the correct directory, skip this step. If you're not, navigate to your repo's directory by using the cd command below.

`cd path/to/repo/`

### Step 3: Check which files have changed.
rmbielby marked this conversation as resolved.
Show resolved Hide resolved

`git status`

### Step 4: Stage the changes you want to commit

- To add changes to one file at a time: `git add <filename>`

OR

- To add all changes: `git add .`

### Step 5: Commit Changes with a message

`git commit -m "Your commit message"`
rmbielby marked this conversation as resolved.
Show resolved Hide resolved

## GitHub Desktop

## VS Code

## RStudio

### Step 2: Select the files you want to record changes for
rmbielby marked this conversation as resolved.
Show resolved Hide resolved

- Tick the files you want to record the changes for.
rmbielby marked this conversation as resolved.
Show resolved Hide resolved
- Click the commit button. It has a tick mark on two sheets of paper.

![](images/r_commit.png)
rmbielby marked this conversation as resolved.
Show resolved Hide resolved

### Step 3: Describe changes and commit

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

- Click "Commit".

![](images/r_commit_msg.png)
rmbielby marked this conversation as resolved.
Show resolved Hide resolved

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

## PyCharm

### Step 2: Open the commit window

- 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){width="461"}

### Step 3: Describe changes and commit

- Tick the files you wish to record changes for.

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

- Click "Commit".

![](images/pycharm_commit_msg.png)
:::
49 changes: 47 additions & 2 deletions git-refresher/syncing-changes-to-remote.qmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,63 @@
---
---
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

### Step 1a: Check that you're in your repo's directory

`pwd`

### Step 1b: Navigate to repo's directory

If you're in the correct directory, skip this step. If you're not, navigate to your repo's directory by using the cd command below.

`cd path/to/repo/`

### Step 3: Sync remote repo with your local one

This step is for updating your remote repo with the changes you made to your local one. You need to do this after committing changes.

`git push origin <branch-name>`

## 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)

### 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)

## 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)

![](images/pycharm_push1_2.png)

### 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)
:::