GitHub brings together the world's largest community of developers to discover, share, and build better software.
To create a GitHub account, perform the procedure below.
- Navigate to the GitHub by clicking https://github.com/. The login page appears.
- Enter relevant information in the following fields:
- Username – Your Username
- Email - Your email address
- Password - Ensure that the password meets either of the following two conditions:
- The word must include at least 15 characters
- The word must include at least 8 characters. One numeric value and a letter in lower case is mandatory.
- Under Email preferences, select the Send me occasional product updates, announcements, and offers check box. This is an optional step.
- Under the Verify your account section, click Verify.
- Using the arrows, rotate the image to achieve accuracy.
- Click Done after you ensure that the image is accurately positioned.
- Click Create Account. An email with a link to verify the created account would be sent to you.
- Click the link to complete the verification process.
Personal Access Tokens (PATs) are an alternative to using passwords for authentication to GitHub when using the GitHub API or the command line. To generate a PAT, perform the procedure below.
- Sign in to GitHub.
- In the upper-right corner of any page, click your profile photo, then click Settings. The Profile page is displayed.
- In the left sidebar, click Developer settings. The GitHub Apps page is displayed.
- In the left sidebar, click Personal access tokens. The Personal access tokens page is displayed.
- Click Generate new token. The New personal access token page is displayed.
- Provide a name for the token in the relevant field.
- Select the scopes or permissions to which you want to grant this token. To use your token to access repositories from the command line, select repo.
- Click Generate token. A token is generated accordingly.
- Copy the token to the clipboard.
To authorize a PAT, perform the procedure mentioned below.
- Sign in to your GitHub account.
- In the upper-right corner of any page, click your profile photo, then click Settings. The Profile page is displayed.
- In the left sidebar, click Developer settings. The GitHub Apps page is displayed.
- In the left sidebar, click Personal access tokens. The Personal access tokens page is displayed.
In Git, the following two aspects are applicable:
- Gitflow
- Dev Branches
To perform the Git configuration, use the following:
- $ git config --global user.name ‘Your Name’
- $ git config --global user.email ‘Your.Name@yourdomain.com’
To fork a repository, perform the procedure mentioned below.
- Login to the GitHub account.
- Navigate to the relevant repository.
- In the top-right corner of the page, click Fork. A fork of the required repository is created successfully.
To clone a repository, perform the procedure below.
Login to your GitHub account, and navigate to the above created fork.
Above the list of files, click the following tab.
To clone the repository using HTTPS, under the Clone with HTTPS section, click the clipboard. To clone the repository using a SSH key, including a certificate issued by your organization's SSH certificate authority, click Use SSH, then click the clipboard.
Open Git Bash.
Change the current working directory to the location where you want the cloned directory.
Type git clone, and then paste the URL you copied earlier. It will look like this, with your GitHub username instead of YOUR-USERNAME.
$ git clone https://github.com/YOUR-USERNAME/repository name
Press Enter. Your local clone will be created. A local copy of your fork of the repository is created.
To configure Git to sync with the fork, perform the following:
- Open Git Bash.
- Change directories to the location of the fork you cloned in the earlier procedure.
- To navigate to your home directory, type cd.
- To list the files and folders in your current directory, type ls.
- To go into one of your listed directories, type cd your_listed_directory.
- To go up one directory, type cd ..
- Type git remote –v, and press Enter. The configured remote repository for your fork is visible.
- Type git remote add upstream, and then paste the URL you had copied. Then, click Enter.
- $ git remote add upstream <<URL>>
- To verify the new upstream repository that you had specified for your fork, type git remote -v again. You should see the URL for your fork as origin, and the URL for the original repository as upstream.
Please note the below mentioned points.
- As per the global naming convention, we've renamed Master to Main branch.
- The Main branch represents the official history, and it must be deployable at any point of time. For every new feature that is being developed, the developer creates a new branch.
- At times, a single branch would be used to deliver a large feature, or prepare for a release.
- Before creating a branch, make sure that all the upstream changes from the main branch is maintained.
- Make sure that you are in the right branch before pulling the commits.
- The checked-out branch must have a “*” as a prefix to the name. If the returned value is not main, then switch to main.
- A new Git branch can be created from the current branch.
Make your code changes, and commit.
When main is the branch, and is ready to pull the updates:
$ git pull origin main
You may have to run the following:
$ git pull origin/feature_x
The Git pull command merges the git fetch and git merge commands.
With each commit, there would be additions and deletions. The following command provides an updated list of files.
$ git status
Run the following command from root of the project to add files individually or in bulk.
$ git add
Run the following command to address additions and deletions.
$ git add –all
When the updates are presented differently, under the heading of Changes to be committed, run the following:
$ git commit -m "<type>(<scope>): <subject>"
To push the new dev branch to the remote repo, perform the following:
Configure Git to always push using the current branch.
$ git config --global push.default current
Push a local branch to a different remote branch.
$ git push origin <local_branch>:<remote_branch>
To create a pull request on GitHub, navigate to the main page of the respective repository, and perform the following:
- Select the appropriate branch from the Branch drop-down menu.
- Click Compare & Pull Request.
- Type a title and description for your pull request.
- Select the reviewers using the menu on the right-side of the window.
- Click Create Pull Request. The pull request is raised successfully.
Rebasing ensures that you have the latest version of main. The procedure is detailed below.
- Consume the commits from your dev branch.
- Temporarily unset them
- Move to the newest head of the main branch
- Commit them again
Note: If there are no issues, conflicts would not occur.
To rebase your local dev branch on the latest version of main:
- $ git checkout main /* ensure you are on the main branch
- $ git pull /* pull the latest from the remote
- $ git push origin PM/cortx-re-testbranch /* update your copy in the repo
- $ git rebase main /* rebase on the main branch
- $ git push origin PM/cortx-re-testbranch --force /* force update the remote
Codacy is an automated code analysis or quality tool that enables a developer to deliver effective software in a faster and seamless manner.
Working of Codacy
You can use Codacy by performing the below mentioned procedure.
- Login to your GitHub account, and navigate to the relevant repository.
- Scroll down the page until you reach the README section.
- Under the README section, click the code quality tab. The Dashboard of the Codacy portal is displayed. You can view the following information:
- Graphical representation of the repository certification
- Commits made in your repository
- Issues reported in your repository
- Files associated with your repository
- Pull requests raised in your repository
- Security status of different parameters
CORTX always requires DCO and may require CLA. To learn more, please refer to DCO and CLA.