Git Hub Usage Manual
GitHub Account Creation And Setup Configuration:
- 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.
- 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.
- Download GitHub Desktop from https://desktop.github.com/ and Git from http://git-scm.com/download/ and install these two applications.
- 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.
- For Git open Git Bash and run $ git config –global user.email “<EmailID>” command, this will configure your account in Git.
Add, Create and Clone Repository:
- 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).
- 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.
- Create – When you want to create new repository that time you have to go for this option.
- 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:
- 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)
- 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.
- Branch name should be descriptive as what this branch is for.
Commit, Stash and Staging:
- 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.
- 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
- 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.
- 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
- 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:
- 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.
- When you have created the new branch than instead of Sync button Publish option will appear.
- 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.
- Please refer the link http://git-scm.com/docs/git-push for more details.
Pull request:
- 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.
- User can create pull requests from GitHub desktop by clicking on pull request link on right top side in GitHub desktop.
- By using GitHub’s @mention system in your Pull Request message, you can ask for feedback from specific people or teams.
- Please refer the link http://git-scm.com/docs/git-pull for more details.
Merge Changes:
- 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.
- User can set the default merge tool, to do so user has to run the command- $ git config –global merge.tool <Merge Tool Name>
- User can also do merging from Git Bash by using the command- $ git merge.
- 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:
- 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.
- 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.