GitHub - The Most Useful Code Committing Platform for Software Developers
When working in a team, you may have come across a situation wherein there are many copies of Code of your Ruby on Rails Application and then you really don't know if it has been updated,well-organized or well merged, for that matter, haven’t you?
Well, GitHub is your solution to the same.GitHub is that platform that I rely a lot on my coding. Be it organizing, updated code or merging code, this platform takes care of it all.
GitHub is a code hosting platform for version control and collaboration. It is a very useful tool that allows you to work in any geographical location.
GitHub is the most powerful platform for management and review of the code. Github is used for managing the code on the single platform. Using GitHub you can track the changes of each commit. Github also provides public and private repositories. The public repository is most commonly used for open source software applications.
- How to create a repository in a GitHub?
- How to create new branches and manage these branches in GitHub?
- How to push your code in GitHub?
- How to manage commits?
- How to create and manage pull request GitHub?.
I’ll start considering you a RoR developer and then, of course, you know how to create your account in GitHub. Well, You should know that!
On Logging into GitHub, you’ll find many options and parameters but for a kick-start to committing codes in GitHub, first, you need to create a repository.
Create a repository in a GitHub :
The GitHub repository is a virtual directory or space where we can access your project, its files, and all related data.
On click of new repository button, you will be redirected to new directory form page. You need to follow the below steps to create a new repository in GitHub.
- Write a valid name for the repository
- Write a short and simple description of the project.
- Click on new repository button to submit the form for creating the repository.
After successful submission of the form, you will be redirected to the Setup page of the created repository.
First of all, take a clone for the projects, you need to make your backup is ready!. Use the following command.
git clone https://github.com/Test/sample-app.git
Then you need to change the directory
If you want to create a new branch by command line and switch to that branch you can use the below command.
git checkout -b NC-2018-06-charts-data
Your branch name should be short and descriptive
You can also change the current working branch by using the below command.
git checkout NC-2018-06-charts-data
Push the code:
Now, once whatever changes you have made in the file you can track by using the below command.
The above commands will list out all of the changes in files.
You can also check what contents and lines have been modified by using the below command. It will list out the changes, the Green color will show the line added and the red color will show line removed
git diff “file_path”
If the files are ready to push you can add these files by using the below command.
git add “file_path”
You can also remove the file from your local system and the remote system.
First, you need to delete the files locally then after executing the command “git status” it will list out the files that have been removed locally, then you need to run.
git remove “file_path”
After adding all the files you can commit the code on the remote server.
git commit -m “The commit message”
After adding all the files you can push the code on a remote server by using the command.
git push origin Rs-2018-06-charts-data
IF you have NOT pushed your changes to the remote repository and just committed the code and then you may want to remove the commit, use.
git reset HEAD~1
If you have pushed your changes and you may want to revert to the previous commit then you need to run the below command.
git revert HEAD
This command will revert/remove the last one commit/ change.
Create and manage pull request:
First, you will have to take the fork of the repository then you can change in the code and commit the code.
On click, or pull request, you can send the pull request to the specified person. After getting the pull request you can click on Merge pull request. Your commits will be merged into the base branch.
So, now you know, how easily GitHub can manage the code -not depending on any locations!!