0% found this document useful (0 votes)
26 views4 pages

VSCode Python Git User Guide

Uploaded by

Borko
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)
26 views4 pages

VSCode Python Git User Guide

Uploaded by

Borko
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/ 4

User Guide for Creating Python Scripts

Using VS Code and Git


Step 1: Install VS Code and Required Extensions

1. Download and Install VS Code:


- Go to the official Visual Studio Code website and download the installer for your
operating system.
- Install VS Code by following the installation instructions.

2. Install Python Extension:


- Launch VS Code.
- Click on the Extensions icon (or press Ctrl + Shift + X).
- Search for Python and install the extension provided by Microsoft.

3. Install Git:
- Download and install Git from Git's official website.
- During installation, ensure that Git is added to your PATH.
- Verify the installation by typing:
git --version

4. Install Git Extension (Optional):


- Install the GitLens or Git Graph extension from the marketplace to enhance Git usage.

Step 2: Clone the Repository

1. Open VS Code Terminal:


- Open the terminal in VS Code by navigating to Terminal -> New Terminal or using the
shortcut Ctrl + ~.

2. Clone the Git Repository:


- In the terminal, clone the repository where the project is stored:
git clone username@server_ip:/home/gitproject
- Replace username and server_ip with the actual credentials.
git clone [email protected]:/project
Step 3: Set Up Your Python Environment

1. Install Python:
- Download Python from python.org if not already installed.

2. Create a Virtual Environment (Optional):


- Inside the project folder, create a virtual environment:
python -m venv venv
- Activate the environment:
- On Windows: venv\Scripts\activate
- On macOS/Linux: source venv/bin/activate

 On the linux server it has already been done for each user

3. Install Required Python Packages:


- If the project has a requirements.txt file, install the dependencies:
pip install -r requirements.txt

Step 4: Write Python Scripts

1. Create a Python Script:


- In VS Code, open the project folder by going to File -> Open Folder.
- Create a new Python file, e.g., script.py, and start writing your code.

2. Run the Python Script:


- Open the terminal in VS Code and type:
python script.py
Step 5: Use Git for Version Control

1. Check the Status of the Repository:


- Use git status to see changes.

2. Stage Changes:
- Stage changes you want to commit:
git add .

3. Commit Changes:
- Commit staged changes:
git commit -m "Message"

4. Push Changes:
- Push changes to the remote repository:
git push origin main

Step 6: Pull Changes from the Remote Repository

1. Fetch and Merge Remote Changes:


- Use git pull origin main to update your local repository.

2. Resolve Conflicts (if any):


- Resolve conflicts, then commit and push the changes.

Step 7: Debugging Python Code

1. Set Breakpoints:
- Click in the left margin next to the line numbers in the code editor.

2. Start Debugging:
- Press F5 or click the Run and Debug icon to start debugging.

3. Use the Debug Console:


- Use the Debug Console to inspect variables and evaluate expressions.
Step 8: Collaboration Using Git

1. Create a New Branch (Optional):


- Create a new branch for your feature:
git checkout -b feature_branch

2. Merge Branches:
- After completing the work, merge the branch back into the main branch:
git checkout main
git merge feature_branch

3. Push the Merged Changes:


- Push the merged changes:
git push origin main

You might also like