Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/ch2.2-create-github-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,25 @@ Your repository is now ready! You can start adding files, cloning it to your loc

## Start the SSH Agent Service

Windows
#### Windows

In Powershell, start the ssh service:

```Powershell
Start-Service ssh-agent
```

Linux
If that does not work, open **Powershell as Administator** and run:

```Powershell
Get-Service ssh-agent | Set-Service -StartupType Manual
Start-Service ssh-agent
Get-Service ssh-agent
```

After successful execution, it should say the service is running.

#### Linux

In the terminal, check if the ssh service is running:

Expand All @@ -84,17 +94,25 @@ This creates a pair of keys:

Run this command to add the private SSH Key to SSH Agent:

#### Linux
```bash
ssh-add ~/.ssh/id_ed25519
```

#### Windows
```Powershell
ssh-add "$env:USERPROFILE\.ssh\id_ed25519"
```

## Get the Public Key Content

Print the public key content to the terminal and copy it:

```bash
cat ~/.ssh/id_ed25519.pub
```
Linux:
`cat ~/.ssh/id_ed25519.pub`

Windows:
`type ~/.ssh/id_ed25519.pub`

## Add the Public Key to your GitHub Account

Expand Down
38 changes: 28 additions & 10 deletions src/ch2.3-using-git.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ From this main code you can create branches, this allows you to make changes wit

Let's create a new branch using this command:

`git checkout -b darshan/feature-a`
`git checkout -b user/feature-a`

You should now be on the `darshan/feature-a` branch. You can check this by running the `git branch` command.
You should now be on the `user/feature-a` branch. You can check this by running the `git branch` command.

Next, let's add a change to this branch

Expand All @@ -118,18 +118,18 @@ hello.txt

### Merging Branches

To update the `main` branch with the changes from `darshan/feature-a`, run this command.
To update the `main` branch with the changes from `user/feature-a`, run this command.

```bash
$ git merge darshan/feature-a
$ git merge user/feature-a
Updating f365571..0d24068
Fast-forward
foo.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 foo.txt
```

If the files modified in `main` and `darshan/feature-a` (after `darshan/feature-a` was created or after the last merge) are mutually exclusive, then git should be able to do this automatically. However, if the same file was modified in both branches, you will encounter a merge conflict. Let's test this.
If the files modified in `main` and `user/feature-a` (after `user/feature-a` was created or after the last merge) are mutually exclusive, then git should be able to do this automatically. However, if the same file was modified in both branches, you will encounter a merge conflict. Let's test this.

First, we'll make a change on the `main` branch.

Expand All @@ -139,7 +139,7 @@ git add .
git commit -m "Update hello.txt"
```

Next, let's make a change on the `darshan/feature-a` branch without updating (merging) the new changes on `main`.
Next, let's make a change on the `user/feature-a` branch without updating (merging) the new changes on `main`.

```bash
echo "Hello engineering students!" >> hello.txt
Expand All @@ -151,7 +151,7 @@ Now let's try to merge this.

```bash
$ git checkout main
$ git merge darshan/feature-a
$ git merge user/feature-a
Auto-merging hello.txt
CONFLICT (content): Merge conflict in hello.txt
Automatic merge failed; fix conflicts and then commit the result.
Expand All @@ -166,7 +166,7 @@ hello world
Hello CSU
=======
Hello engineering students!
>>>>>>> darshan/feature-a
>>>>>>> user/feature-a
```

To resolve this, replace the text above with the final desired version (it could be one or the other, or a combination of both). Once you've resolved all of the conflicts in (and saved) each file, stage the files and create a new commit. This completes the merge process.
Expand All @@ -188,10 +188,10 @@ git commit -m "Merge feature-a into main"

**Note:** you can also use `git commit` without a commit message. It will then open an editor for you the write the commit message. once you save the message and exit the editor, git will make the commit.

Afterwards, you may delete `darshan/feature-a`.
Afterwards, you may delete `user/feature-a`.

```bash
git branch -d darshan/feature-a
git branch -d user/feature-a
```

## Remotes
Expand Down Expand Up @@ -237,3 +237,21 @@ Visual Studio Code has integrated source control management (SCM) and includes G
- https://code.visualstudio.com/docs/sourcecontrol/overview

- https://www.gitkraken.com/blog/vs-code-git

### Git Best Practices

- Commit Often: Make small, frequent commits to capture your progress.

- Write Clear Commit Messages: Use descriptive messages that explain why a change was made, not just what changed.

- Use Branches: Create branches for features, fixes, and experiments to keep your main branch stable.

- Pull Before You Push: Always `git pull` before pushing.

- Review Changes Before Committing: Use `git status` and `git diff` to review your changes before you commit.

- Keep Repositories Small: Avoid adding large files or unnecessary dependencies.

- Use .gitignore: Exclude files that shouldn't be tracked (like build artifacts, log files, or secrets) by adding them to a `.gitignore` file.

https://www.w3schools.com/git/git_best_practices.asp