- Install Git (if not already installed):
- Download Git and set it up on your machine.
- Open VSCode:
- Go to View > Command Palette or press
Ctrl + Shift + P
. - Search for
Git: Clone
and select it.
- Go to View > Command Palette or press
- Provide the Repository URL:
- Paste the GitHub repository URL (HTTPS or SSH) and press
Enter
.
- Paste the GitHub repository URL (HTTPS or SSH) and press
- Select a Folder:
- Choose a folder on your local machine where the repository will be cloned.
- Open the Project:
- When prompted, open the cloned repository in VSCode.
- Open the Branch Menu:
- In the bottom-left corner of VSCode, click the branch name (e.g.,
main
).
- In the bottom-left corner of VSCode, click the branch name (e.g.,
- Create a New Branch:
- Select Create new branch.
- Enter a name for your new branch (e.g.,
feature-xyz
) and pressEnter
.
- Switch to the New Branch:
- After creating the branch, VSCode will automatically switch to it. If not, manually select it from the branch menu.
- Edit Files:
- Make the necessary changes to the files in the project.
- Stage Changes:
- Go to the Source Control view (icon with three branches) or press
Ctrl + Shift + G
. - Click the
+
icon next to the files you’ve modified to stage them.
- Go to the Source Control view (icon with three branches) or press
- Commit Changes:
- In the message box, write a meaningful commit message (e.g.,
Add new feature
) and pressCtrl + Enter
.
- In the message box, write a meaningful commit message (e.g.,
- Push the Branch:
- Open the terminal in VSCode (
Ctrl + ~
) and run:Replacegit push -u origin <branch-name>
<branch-name>
with the name of your branch.
- Open the terminal in VSCode (
- Verify on GitHub:
- Go to the GitHub repository page to ensure your branch appears in the list.
- Navigate to the Repository on GitHub:
- Open the repository in your browser.
- Create a Pull Request:
- Click Pull Requests > New Pull Request.
- Select your branch as the source and
main
(or the target branch) as the destination. - Add a title, description, and reviewers if needed, then submit the PR.
- Fetch Updates Regularly:
- Keep your branch up to date with the latest changes from the main branch:
git fetch origin git merge origin/main
- Keep your branch up to date with the latest changes from the main branch:
- Resolve Conflicts:
- If conflicts occur during merging, VSCode will highlight them in the editor. Resolve the conflicts, stage the files, and complete the merge.
- Pull Changes from Others:
- If others push updates to the repository, pull the changes into your branch:
git pull origin <branch-name>
- If others push updates to the repository, pull the changes into your branch: