Thursday, February 16, 2017

All about version controlling tools - GitHub / bitbucket Part - 2

In the part 2 of this series, we'll look at how to use GitHub with console.

1. Adding your local project to an empty gitbub repository's master branch

  1. Goto the github and create an empty repository.
  2. Then goto the empty repository.
  3. Copy the https or ssh url
  4. Then create a folder locally, in your computer to initialize the repository.
  5. Now "CD" into the created folder using command line.
  6. In the command line type the following commands in order to initialize the repository.
    1. Now copy your project to the newly created folder
    2. git init  #This command is used to start using git on a project that's not under git
    3. git add .
    4. git commit -m "initial commit"
    5. git remote add origin https://github.com/yourprofile/yourproject.git
    6. git push -u origin master #you can add different origins in order to push your local project to GitHub.
  7. Now that you have successfully copied the project into the GitHub, you can make changes to the code locally.
  8. If you are hoping to further develop the software. you'll have to create a developer branch. Let's think that you're going to further develop the software. Let's create the developer branch. when you create a developer branch, the code in the master branch will be automatically copied to this branch.
    1. git branch developer #this command creates a developer branch.
  9. Now before continuing further, set the default branch to developer branch.
    1. Goto settings on GitHub repo.
    2. Select branches tab
    3. Set the default branch 
  10. Then, to continue development, let's create a feature branch from the developer branch 
    1. git branch -b feature/new-component developer
  11. Let's switch to the feature/new-component branch.
    1. git checkout feature/new-component
  12. push it to the feature/new-component
    1. git add --all
    2. git commit -a -m "describe your changes here"
    3. git push -u origin feature/new-component
  13. Then once you have finished developing the particular feature, create a pull request to the developer branch and merge the code.
  14. Once you have completed an iteration of the software or the full software, create a pull request to the master branch from developer branch and merge the code with master branch
    1. create a pull request to the master branch from developer branch.
    2. merge the code with the master branch.
We are using the developer branch only for the purpose of further development and it will be merged to the master branch when you have completed an iteration of the software / program only, as an engineering best practice.

Important points to remember
  • If you have a team or if you are doing a group project, a feature branch must be created for each developer and the code should be push to that feature branch. When you have completed the development of a particular feature, then you can merge the feature branch with the developer branch.
  • If your team or group is fixing the bugs, bugs/identifier branch should be created for each member and merge the fixes to the developer branch. 
part 3

2 comments: