Showing posts with label intro. Show all posts
Showing posts with label intro. Show all posts

Monday, February 20, 2017

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

2. Multiple users working on the same branch.

If two or more users are using the same repository to push code into, there will be conflicts. In order to resolve the issues checkout the steps below.

Let's take an example. Suppose that you already have a codebase in GitHub

|-- master
|-- dev(default)
    |-- feature/myfeature *

In the team what if 2 users are working on the same feature. So that they'll have to use the same branch(Not a good practice though). Let's take our 2 users as USER1 and USER2. Suppose that the USER1 and USER2 have already cloned the repo into the local machine.
git clone <ulr here>
Now both the users are working on the project. They have to stick with few guidelines in order to prevent from conflicts. 

1. Whenever they have completed something, commit locally but do not push to the feature/myfeature branch.

2. When ever they want to push the code to the branch follow the steps given below.
  1. git add --all
  2. git commit -m "your changes"
  3. git pull
  4. After pulling, there can be conflicts in the local code. You have to correct them manually and then 
  5. git commit -m "new changes" 
  6. and finally
  7. git push -u origifeature/myfeature
  8. if you get an error message, then repeat steps 3 to 7 again.

3. What is the difference between 'git pull' and 'git fetch'?

git pull is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches. In the simplest terms, git pull does a git fetch followed by a git merge.




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

Wednesday, February 15, 2017

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

1. What is "version control", and why should you care?

"Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later"

As defined about, If multiple people are developing a software, the version controlling tools may come in handy. Let's get started.

2. Github

Once you have registered with GitHub you'll be able to create a repository easily. Repository is a place where you are going to upload the code into. 
In a repository there are branches. A branch represents an independent line of development. Branches serve as an abstraction for the edit/stage/commit process.

3. The branch structure

Master branch : This is where the production code goes into. After completion of an release of the program / software, we create a pull request( Simply allows the user to notify others about the completion. Then other users can review the code and merge the code ) to the master branch from developer and merge the code with the master branch after a code review.

Developer branch : This is where the non production code goes into. When the software is being developed, the users can merge their developments with this branch after creating a pull request.

Feature branch : These are the branches where features of the main software are developed in. When a developer completes a certain feature of the software, this branch will be merged with the developer branch.

Bug fix branch : All the bug fixing will be done using this branch. After fixing a certain bug, this branch will be merged with the developer branch after creating a pull request.

When you have all the above branches, your repo may look like this : 

|-- master
|-- developer
    |-- feature/toolbox
    |-- feature/custom-view-controller---ios
    |-- feature/floating-button---ios
    |-- bugfix/error-302-navigation-controller-error
    |-- bugfix/error-701-runtime-error---ios



Terms :
  1. Origin - origin is an alias on your system for a particular remote repository url. It's not actually a property of that repository.
    1. git add origin <url here>
  2. Remote - Remotes are simply an alias that store the url of repositories. You can see what url belongs to each remote by using.
    1. git remote -v
  3. Fork - It only allows clone on the server side.
  4. Upstream - The original repo