[OSD600]Git remotes, git revert

Trang Nguyen
2 min readOct 8, 2021

--

I was having a busy week as I had to prepare for my interviews. It’s not until I read the messages on Slack and found out that I still need to submit a lab by Friday. Oops! All Javascript repositories were picked and only C# left. And I had no other choices …

This is the first time I have seen C# codes on Diana’s repo. I was having difficulties with running the project at first but thanks to Diana’s help. I was able to get it up and running.

I just have 01 day left and I completed it in 02 hours and a half. I did this by asking my friend who is a newbie with C#. He helped me to install the library, get familiar with Visual Studio Code’s tools and syntaxes. All of the codes and the approaches were written by myself.

STEP 1: Work on Diana’s repo

I created an issue and forked his repository as well as creating a branch called issue-11.

My approach is to read the .json file => parse the content to Json’s object by using a .NET’s library => assign them to current arguments so that I can reuse the old codes.

STEP 2: Create a draft pull request

I created a draft pull request to let Diana know that I’m working on. Lucky for me, she’s online at the time.

Diana’s repo

Step 3: Work on my repo

Actually, I got a pull request from Andrew but I didn’t think that it was for lab4. After reading his codes, I was pretty sure that my program would run without crashing and I accepted his merge request without actual testing.

Three days later, I read lab4 carefully and found out that I made a mistake. I should have created remotes and did some testing on Andrew’s branch. Silly me!

I had to revert the pull request from the remotes and revert the codes from my local machine (I accidentally did pull origin main when I was at`main` branch.

Here’s how I did the revert in my local machine:

git log --oneline To check the position of the head

git reset -—hard commitNumber set HEAD to the previous position

git clean -fd

git push -f origin main

I also revert the pull request from the browser by clicking the closed pull request and revert it.

Step 4: Test and manually merge

I used the command:

git remote add Andrewnt219 https://github.com/ritikbheda/cmd-ssg.git

then

git fetch Andrewnt219

which fetches his support-for-config-file’s branch

Then I did

git checkout -b support-for-config-file Andrew219/support-for-config-file

which creates my own local copy of his branch on my computer.

I proceed to test the code, then I will do a merge to main branches when it’s completed.

$ git checkout main

$ git merge Andrewnt219/support-for-config-file

$ git push origin/main

Andrewnt209’s repo

Happy coding!

--

--

Trang Nguyen

Computer Programming Student @Seneca. Writing to share solutions and encourage my sister to write.