Simple Git Tutorial

Git Workflow (Image courtesy WSO2 Team)
  1. Fork the repository that you want to work with by visiting the Git repository and clicking the “Fork” button in the top right-hand corner. We’ll be using the below repository as the example in this tutorial.

git clone git@github.com:<username>/solution-architecture-patterns.git

5. Point the pull URL to the original repo

git remote set-url origin git@github.com:chanakaudaya/solution-architecture-patterns.git

6. Point the push URL to the forked repo {note the (minus)(minus)push in the command}

git remote set-url — push origin git@github.com:<username>/solution-architecture-patterns.git

7. Check whether you have configured the repositories correctly by executing the below command

git remote show origin

You should see something like below as the response.

git commit -m “commit message”

9. Update your changes to the remote repository forked into your account with the below commands

git pull (pull the changes from the original repository)

git push (push the local changes to the remote forked repository)

10. Go to the forked repository and send a PR (Pull Request) to the original repository from GitHub.

git checkout -b feature1 master

12. Make sure you are in the created branch by executing the below command

git branch

You should see the branch name in the output to the above command

git commit -m “commit message”

14. Once you commit the changes to the new branch, switch back to the master branch with the below command

git checkout master

15. Update the master branch with any changes that happened at the original repository with the following commands

git pull

git push

16. Switch back to the feature1 branch with the below command

git checkout feature1

17. Now rebase the master branch so that you save the commit history from the master branch and append your work to the same history with the below command

git rebase master

18. If there are any conflicts, you can resolve those conflicts and once you are done with the resolution, push the changes to the remote (forked) repository with the below command

git push origin feature1

19. Now you can go to the repository and send a PR (Pull Request) from “feature1” branch to “master” branch of the original repository

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chanaka Fernando

Chanaka Fernando

Writes about Microservices, APIs, and Integration. Author of “Designing Microservices Platforms with NATS”