[go: up one dir, main page]

0% found this document useful (0 votes)
14 views5 pages

Git Workflow and Virtual Environment Summary

Uploaded by

jeetraj731
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views5 pages

Git Workflow and Virtual Environment Summary

Uploaded by

jeetraj731
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Git Workflow and Virtual Environment

Summary
Git Workflow
1. Forking a Repository:
- Fork the repository on GitHub. This creates a copy of the original repository in your
GitHub account.

2. Cloning the Forked Repository:


```sh
git clone https://github.com/your-username/repository-name.git
cd repository-name
```

3. Creating a New Branch:


- Best practice to keep your changes isolated.
```sh
git checkout -b my-new-feature
```

4. Making Changes and Committing:


- Make your code changes.
- Stage the changes:
```sh
git add .
```
- Commit the changes with a descriptive message:
```sh
git commit -m "Descriptive commit message about what you changed"
```

5. Pushing Changes to Your Forked Repository:


```sh
git push origin my-new-feature
```

6. Creating a Pull Request:


- Go to your forked repository on GitHub.
- Click `Compare & pull request`.
- Add a descriptive title and description.
- Click `Create pull request`.
7. Syncing Forked Repository with Original Repository:
- Add the upstream repository:
```sh
git remote add upstream https://github.com/original-owner/repository-name.git
```
- Fetch updates from upstream:
```sh
git fetch upstream
```
- Merge changes into your local main branch:
```sh
git checkout main
git merge upstream/main
```

8. Resolving Conflicts:
- If there are merge conflicts, resolve them manually in your code.
- After resolving conflicts, stage the resolved files:
```sh
git add .
```
- Commit the resolved changes:
```sh
git commit -m "Resolved merge conflicts"
```
- Push the resolved changes:
```sh
git push origin my-new-feature
```

Creating and Applying Patch Files


1. Creating a Patch File:
- After making and committing changes, create a patch file:
```sh
git format-patch -1
```

2. Applying a Patch File:


- Apply the patch file in another repository or another clone:
```sh
git apply your-patch-file.patch
```
Virtual Environment
1. Creating a Virtual Environment:
```sh
python -m venv venv
```

2. Activating the Virtual Environment:


- On Windows:
```sh
.\venv\Scripts\activate
```
- On macOS/Linux:
```sh
source venv/bin/activate
```

3. Installing Packages in the Virtual Environment:


```sh
pip install package-name
```

4. Freezing Requirements:
- Create a `requirements.txt` file to record the dependencies:
```sh
pip freeze > requirements.txt
```

5. Deactivating the Virtual Environment:


```sh
deactivate
```

Common Errors and Troubleshooting


1. Syntax Errors:
- Ensure correct syntax, for example:
```python
prices = {}
```

2. ZeroDivisionError:
- Check and handle division by zero:
```python
if price_b == 0:
return
return price_a / price_b
```

3. Correct Tuple Structure:


- Ensure the correct structure in function returns and prints:
```python
stock, bid_price, ask_price, price = getDataPoint(quote)
print(f"Quoted {stock} at (bid:{bid_price}, ask:{ask_price}, price:{price})")
```

4. Pushing and Pulling:


- Always ensure to push changes to the correct branch and create a pull request from the
same.

Useful Commands Summary


- Fork Repository on GitHub

- Clone Repository:
```sh
git clone <repo-url>
```

- Create Branch:
```sh
git checkout -b <branch-name>
```

- Stage Changes:
```sh
git add .
```

- Commit Changes:
```sh
git commit -m "Your commit message"
```

- Push Changes:
```sh
git push origin <branch-name>
```

- Create Pull Request on GitHub


- Sync with Upstream:
```sh
git remote add upstream <upstream-repo-url>
git fetch upstream
git checkout main
git merge upstream/main
```

You might also like