Basic Git Hub Usage Manual

Git Hub Usage Manual

GitHub Account Creation And Setup Configuration:

  1. Need to create an account on https://github.com with official email id. And also activate two factor authentication and set profile picture over there. Once done with these inform Jaco about it, so he can add you in the CeX organization account.
  2. Now create the Personal Access Token from the Settings, it will be useful when we want to push the changes to the remote through Git Bash.
  3. Download GitHub Desktop from https://desktop.github.com/ and Git from http://git-scm.com/download/ and install these two applications.
  4. When you start GitHub desktop, you have to login over there. To login on GitHub Desktop goto Tools And Options and then in Options you will find the add account option.
  5. For Git open Git Bash and run $ git config –global user.email “<EmailID>” command, this will configure your account in Git.

Git vs GitHub

Add, Create and Clone Repository:

  1. Now as all tools are set, it is time to clone the repository from github. To do so goto GitHub desktop and click on “+” icon at left top most location, you will get three options there Add, Create, Clone(Clone option only comes if you logged in to GitHub Desktop).
    1. Add – When you have repository and want to see it in GitHub Desktop that time you have to go for Add option. You have to provide the path of the git repository. Usually when we migrate any project from vss to git, that time will use it.
    2. Create – When you want to create new repository that time you have to go for this option.
    3. Clone – When you have a repository on github and wants to work on it, that time you have to make a clone of that. It will clone that repository on the clone path set in your account. You can change clone path from Tools and Options and then in Options, you will find clone path location. If you are a member of any organization than you can view the organization in clone section. By clicking on it you will get the available list of repositories in that organization and you can then make a clone of it.

Branching:

  1. For now we are using GitHub flow for creating branch and merging and all. Please refer the link http://scottchacon.com/2011/08/31/github-flow.html for details. (i.e. there will be only one Master branch and from which developers will create branches. Branches may be for associate points, new features, hotfixes)  
  2. For any assigned point, you need to create new branch from the Master branch and start doing your changes. To create branch in github desktop, there is on top side option is available. Available branch list is also there i.e. from which we want to create new branch.
  3. Branch name should be descriptive as what this branch is for.

 

Commit, Stash and Staging:

  1. Once you do any changes, in GitHub Desktop on top side, it will show like how many uncommitted changes are there. When you click on anyone of the uncommitted changes it will show you the changes done by you. And also give you the option to commit the changes.
  2. To commit you have to provide the Summary and Description for the same and you can commit it. You can do commit from Git Bash also please refer the link for more details https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
  3. Please remember once user is in between of certain changes than he can not switch to other branch until he commits the changes or stash it.
  4. Stash and Staging option is not available from Github Desktop. We can do it from Git Bash. Stage is the process of adding files to the list, which we want to commit. To stage files use the command- $ git add <filename>. Please refer the link for more details https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
  5. Stash is like when user is in between of certain changes and task has not yet done. But due to some urgency he has to work on some other task, so he can not commit the work which is in progress, so he can stash it and continue with other task. User can do it by using the command- $ git stash . Once the other task is done and user wants to resume the task which he left in between, user can do it by the command-   $ git stash pop . Please refer the link for more details http://git-scm.com/docs/git-stash

 

Push changes to remote:

  1. To push the changes to the remote repository using GitHub desktop, user has to click on the Sync button which is located on the right side within the branch graph chart.
  2. When you have created the new branch than instead of Sync button Publish option will appear.
  3. You can also push your changes through Git Bash, for that you need to run the following commands- $ git remote add origin <Repository Url> then run the command- $ git push -u origin master, it will ask for authentication. Enter your username and for the password give personal access token. And it will push all your changes to the remote repository.
  4. Please refer the link http://git-scm.com/docs/git-push for more details.

 

Pull request:

  1. Pull requests initiate discussion about your commits. Pull Requests help start code review and conversation about proposed changes before they’re merged into the master branch.
  2. User can create pull requests from GitHub desktop by clicking on pull request link on right top side in GitHub desktop.
  3. By using GitHub’s @mention system in your Pull Request message, you can ask for feedback from specific people or teams.
  4. Please refer the link http://git-scm.com/docs/git-pull for more details.

 

Merge Changes:

  1. GitHub automatically handles the merging of changes. But if it finds any conflicts and won’t be able to merge then asks user to resolve the merge conflict.
  2. User can set the default merge tool, to do so user has to run the command- $ git config –global merge.tool <Merge Tool Name>
  3. User can also do merging from Git Bash by using the command- $ git merge.
  4. Please refer the link http://git-scm.com/docs/git-merge for more details.

 

Rebasing:

For Rebasing please refer the following links.

https://git-scm.com/book/en/v2/Git-Branching-Rebasing

https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase/

http://www.git-tower.com/blog/understanding-rebase-merge-in-git/

 

History:

  1. In GitHub desktop, on top side History option is there. It will show you the entire history details. Along with history, it also shows in that particular history how many files are changed and even changes as well.
  2. From Git bash also user can view the history details by using the command- $ git log –oneline. User can also checkout the particular history revision by using the command- $ git checkout <Revision Checksum>(i.e. unique id, which appears while we running $ git log –oneline command).

Please note, you can explore new tools like Source Tree etc.

Leave a Reply

Your email address will not be published. Required fields are marked *