In PART 1, we learnt how to create a new repository in GitHub and learnt how to push the project from eclipse to GitHub.
In this we will learn how to create a branch in GitHub and how to work on our branch in eclipse without disturbing the master.
After this if we check in our repository we can see our project.
All the files what we created in the project (in eclipse) has been pushed in this.
Step 5: Creating a new branch in GitHub.
To create a new branch click on master, you get a dropdown, there you can create a branch
Note: Always create branch, once you push the code to master.
Now all the files in the master, will be there in your branch too(in GitHub).
Step 6: Switch to your branch from master in Eclipse.
· Right click on your project (in Eclipse), select ShowIn --> Terminal
· A new terminal window is opened in Eclipse.
· Then type git status and enter --> It will show we are in master branch.
· Now to switch branch from master to your branch(What we created in GitHub), then type git fetch origin and enter
· This will show all the branches created in the repository including master branch.
· Then type git branch your_branch_name(what you created in GitHub) and enter.
· Then type git checkout your_branch_name and enter. Now you have switch to your branch in Eclipse.
· Just refresh the project and it is switched.
· You are in your branch and good to start working and this will not be impacted in the master branch.
· To push the new code what you are working , repeat the process of Step 4.
Hope you get an idea of basic working of GitHub. (Creating repository, pushing the codes, switching to your branch).
Thanks for Reading.