Getting Started with Our Repository in VSCode #6
Closed
doctorbanu
started this conversation in
General
Replies: 2 comments 1 reply
-
Hi guys! 🙋🏻♀️ I added a guide for Git commands that can be useful for us. And I tried to include the important things to keep in mind. I know it seems a little bit too long, but I am going to add a summary for it. However, it could be better if you can check the original version. |
Beta Was this translation helpful? Give feedback.
1 reply
-
We added this to Notes Folder. Thank you Banu! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
A Beginner's Guide to Working with Git Repos in VSCode
🖇️ Cloning the Repository 🖇️
a) We can open VSCode, and on the main page, click on
"Clone Git Repository".
b) Alternatively, we can open the terminal and run the following command
for our Repo:
git clone https://github.com/MIT-Emerging-Talent/ET6-foundations-group-05.git
🌿 Branch Creation and Commands for Branch Management 🌿
a) Check status of our working directory and staging area
git status
b) Check existing branches (local)
git branch
c) Check all branches (local and remote)
git branch --all
d) Update our local repository to the latest version of main
git pull origin main
e) Merge another branch into your current branch
git merge another_branch_name
f) To switch between branches
git switch name_of_wanted_branch
g) Create a new branch and switch to it
git checkout -b name_of_new_branch
git branch name_of_new_branch
git switch name_of_new_branch
h) Delete branches
git branch -d branch_name
git branch -D branch_name
git push origin --delete branch_name
🚀 Making and Pushing Changes to GitHub 🚀
1. Staging Changes
❗Avoid using
git add .
include unrelated files or changes and cause conflicts.
Preferred Alternative: Add specific files only with:
git add folder_name/file_name
2. Committing Changes
git commit -m "Descriptive message, e.g., Added solution and tests for challenge_name"
3. Pushing to GitHub
git push origin branch_name
🔄 Pull Requests and Reviews 🔄
1. Creating a Pull Request (PR)
a) If our branch is recently pushed, GitHub will display a Compare & Pull Request
button.
b) Alternatively, we will:
2. Reviewing a Pull Request
If we are reviewing someone else's pull request. We will:
🔗 Merging 🔗
Once the PR is approved, we need to click the green "Merge pull request" button
and then "Confirm merge". After successful merge, our changes will be added to
the main branch.
🎉 And, congratulations! Once the PR is merged, our solution is part of the repository.
Handling Merge Conflicts
If we get conflicts while merging main into our branch:
git switch main
and then,git pull origin main
git switch our_branch
git merge main
which files have conflicts that need to be resolved.
conflict markers (like <<<<<<<, =======, and >>>>>>>). We need to edit the files
manually to resolve the conflicts and keep the desired changes.
need to add those files to the staging area:
git add resolved_file
git commit -m "Merge main and resolve conflicts"
Beta Was this translation helpful? Give feedback.
All reactions