Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the skills to improve efficiency with Git and Github

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Most people don't understand the knowledge points of this article "What are the skills to improve efficiency with Git and Github", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "What are the skills to improve efficiency with Git and Github".

GitHub

Shortcuts: t and w

On your source browsing page, press t to quickly enter fuzzy filename search mode:

On your repository home page, press w to quickly filter branches:

On any GitHub page, press? Display the shortcut keys available on the current page:

Ignore spaces: ? w=1

Add to arbitrary diff URL? w=1 is used to organize indentions:

Filter commit records by scope: master@{time}.. master

You can create a comparison page by using the URL github.com/user/repo/compare/{range}. A range can be two SHA's such as sha1…sha2 or two branch names such as master…my-branch. Scope is also very intelligent in supporting the use of time as a focus.

You can filter submissions from yesterday via master@{1.day.ago}…master. For example: link https://github.com/rails/rails/compare/master@{1.day.ago}... master shows all commits and changes in Rails project that started yesterday:

Filter submission records by author: ? author=github_handle

You can do this by adding? to the URL of the comparison page. author=github_handle to filter submission records by author. For example: link github.com/dynjs/dynjs/commits/master? author=jingweno shows jingweno's submission history for Dynjs:

.diff and.patch

Add.diff or.patch to the URL of a comparison page, merge request page, or review page to get the diff or patch text format. For example: the link https://github.com/rails/rails/compare/master@{1.day.ago}... master.patch displays all the commit records and changes in the Rails project from yesterday. Text format:

email reply

You can comment directly on the GitHub notification email you receive instead of commenting on the site page. GitHub will handle your comments correctly:

link line

Click on a line or select multiple lines by pressing SHIFT on the file display page and the URL changes accordingly. If you want to share a piece of code with your teammates, it's very convenient:

attention to the user

Mentioning the user in a merge request, question, or any comment will draw the user's attention to all subsequent notifications:

automatically linked

In merge requests, questions, or any comments, sha and question code (e.g.#1) are automatically linked. Also, you can link sha or question codes from other repositories in the format user/repo@sha1 or user/repo#1. Here's an example of a comment linked automatically via sha:

hub

Hub is the command line for GitHub. It provides integration between Git and Github. One of the most useful commands is to create a pull request by typing hub pull-request on the command line. See readme.

Git

git log -p FILE

View the modification history of README.md, for example:

git log -p README.mdgit log -S’PATTERN’

For example, search for a history of modifications that match Stupid:

git log -S'stupid'git add -p

Interactive save and unsave changes using:

git add -pgit rm –cached FILE

This command deletes only remote files, such as:

git rm --cached database.yml

Delete database.yml saved records without affecting local files. This is very convenient for deleting pushed ignore file records without affecting local files.

git log .. BRANCH

This command returns commit records for a non-HEAD branch. If you are in a functional branch, enter:

git log .. master

Returns the history of all master branches, including commits that were not merged into the current branch.

git branch –merged & git branch –no-merged

This command returns a list of merged branches or a list of unmerged branches. This command is useful for pre-merge checking. For example, in a functional branch, enter

git branch --no-merged

Returns a list of branches that have not been merged into this branch.

git branch –contains SHA

Returns a list of branches containing a specified sha. For example:

git branch --contains 2f8e2b

Show all branches containing commit 2f 832b. This command is helpful for verifying that git cherry-pick is complete.

git status -s

Returns a simple version of git status. I set this command to default to git status to reduce noise.

git reflog

Displays a list of actions you have completed locally.

git shortlog -sn

Displays a list of participants who submitted records. Same list of participants as GitHub.

Summary

Git is a well-designed tool. Understanding it can directly make you more productive and a more talented programmer. GitHub, on the other hand, provides convenient teamwork features on top of Git. Having the ability to use GitHub will also improve your daily productivity.

The above is the content of this article about "What are the skills to improve efficiency with Git and Github". I believe everyone has a certain understanding. I hope the content shared by Xiaobian will help everyone. If you want to know more relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report