EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

GitHub Commands

Home » Software Development » Software Development Tutorials » Github Tutorial » GitHub Commands

GitHub-Commands

Introduction to GitHub Commands

GitHub is very much popular web-based application in current industry for hosting variety services targeting version control using GIT commands. It offers various distributed version controlling as well as source code management properly.

Basic Commands

Some of the basic commands used by GitHub are as follows:

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

  • Commands for getting existing projects and create one new GITHUB projects:
  1. Git init: Suppose developer needs to prepare one new repository in his local environment. For initializing the same they have to use init commands, which helps them for initializing GitHub project repository locally.
  2. Git clone ssh://something.com/[username]/[repository_name].git: Suppose developer needs to create one specific repository of GITHUB in their local copy from the specific remote location. Then they have to execute clone command for copying the same remote repository in the local environment in specific location.
  • Some of the basic commands  for continuing with GITHUB:
  1. Git status: This GitHub command is mainly used for identifying GIT created status in local repository. It provides proper information between a syncing status of local and GITHUB repository to the end user.
  2. Git add [file_name.doc]: Used for adding one specific file in staging area.
  3. Git add –A: Adding all the files whether it is new or modified will be added in the staging area.
  4. Git commits –m [“message for commit”]: Commit all the required changes.
  5. Git rm –r [file_name.doc]: Helping for removing the file or any defined folder.

Intermediate Commands

There are several other popular commands which are used by the developer, which are not very basic commands but working with GITHUB more, those commands are very much required to execute. Some of these kinds require intermediate commands which are mentioned below:

  • Command for Branching and Merging multiple projects commits codebase:
  1. Git branch: This is very much a useful command for using any kind of GITHUB set up for your projects. It normally provides entire branch information in a list. Asterisk denotation is also given which points the exact current project.
  2. Git branch -a: This is helping for listing all the available branches considering all the locations of the branches, it can be local or remote. It is one of the key commands for identifying all the available projects in GITHUB environment.
  3. Git branch [branch_name]: Creating a new branch with new name.
  4. Git branch –d [branch_name]: Deleting a specific branch.
  5. Git push origin –delete [branch_name]: Deleting a branch from the remote environment.
  6. Git checkout -b [branch_name]: Helping to create one specific new branch and switching entire codebase to it.
  7. Git checkout –b [branch_name] origin/branch_name: Helping for cloning one remote branch and switching entire codebase to it.
  8. Git checkout [branch_name]: Switching to a defined branch.
  9. Git checkout – Switching to a specific branch which absolutely checks out last.
  10. Git checkout – [file_name.doc]: Avoiding or discarding the last changes in the specific file.
  11. Git merges [branch_name]: Helping for merging one specific branch with one of the other activities available branches.
  12. Git merges [source_branch] [target_branch]: Helping for merging with specified sourcing branch and specified target branch.
  13. Git stash: Stash helps in some of the specific changes to define dirty directory immediately.
  14. Git stash clear: Removing all the stash entries from the dirty working directory.

Advanced Commands

Still, some of the critical tasks need to be done by the GitHub users frequently. Those tasks also have some advance kind of commands which needs to be executed, and which are mainly used by some of the managerial people for understanding projects status comparing other existing project and also sometimes used for sharing some project knowledge with others. These advanced commands are mentioned below:

  • Commands for updating or sharing projects data:
  1. Git push origin [branch_name]: Helps for pushing one of the created branches in your local environment to a remote directory or repository.
  2. Git push –u origin [branch_name]: It does the similar task like above, pushing entire local repository branch to the remote repository, extra utility of using this command is also remembered for this specific branch for future reference.
  3. Git push: Again it does the same task, pushing entire local repository data to remote, but do not need to mention the branch name, it will pick up branch name directly from the last remembered branch.
  4. Git push origin – delete [branch_name]: Deleting specified branch.
  5. Git pull: Helping for updating all the newest commit in the mapping local repository.
  6. Git pull origin [branch_name]: Helping for pulling entire changes from the remote repository to local.
  7. Git remote add origin ssh://something.com/[user_name]/[repository_name].git: Helping for mapping local repository’s origin branch with remote repository through SSH.
  • Commands for Comparison or specific inspection on GITHUB repository:
  1. Git log: Displaying all the log information of one specific project, which can provide every information with committed changes.
  2. Git log –summary: Provide more log details for identifying specific members who committed the same.
  3. Git diff [source_branch] [target_branch]: This one normally is used before merging on a specific document. It helps for displaying current changes done on the existing document.

Tips and Tricks to Use

Some common users who very frequently use GitHub utility normally use some of the tips and tricks for utilizing GitHub commands output in proper way. Those kinds of tricks are normally used for solving some user-specific queries and display screening output for understanding the same properly. Some of the very commonly used key tricks are:

  • Suppose GitHub user needs to identify the difference between two versions of the document. In that case, if that document holds a lot of whitespaces, it will also display the same. So user sometimes needs to ignore those whitespaces, so one of the very commonly used tricks for that is ‘?w=1’, which helps to display only the code changes without any whitespace.
  • GitHub user needs to display those changes which are committed by one specific user, so including query string like ‘?<user_name>’ will give them the result of all the committed changes done by that specific user.

Conclusion

Github is one of the key repository tool currently available in the industry. A lot of organization are really willing to use GitHub due to their repository mechanism, and well documentation on internet. Github also provides proper view representation from there anyone will be able to commit or checkout easily. All those commands may not be required to be executed. But still executing command performance is always been better than normal view.

Popular Course in this category
GitHub Training (2 Courses, 3 Project)2 Online Courses | 3 Hands-on Project | 5+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (5,110 ratings)
Course Price

View Course

Related Courses
Kali Linux Training (3 Courses, 3+ Projects)All in One Financial Analyst Bundle (250+ Courses, 40+ Projects)

Recommended Articles

This has been a guide to GitHub Commands. Here we have discussed basic, intermediate as well as advanced GitHub Commands along with tips and tricks to use. You may also look at the following article to learn more –

  1. HBase Commands
  2. Hive Commands
  3. Tableau Commands
  4. Spark Commands

GitHub Training (2 Courses, 3 Project)

2 Online Courses

3 Hands-on Project

5+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
Github Tutorial
  • Basics
    • How To Install Github
    • GitHub Commands
    • GitHub Clone
    • GitHub Interview Questions

Related Courses

GitHub Training Course

Kali Linux Training

Software Development Course Training

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - GitHub Training (2 Courses, 3 Project) Learn More