Skip to content

Latest commit

 

History

History
60 lines (38 loc) · 3.9 KB

Git-and-GitHub.md

File metadata and controls

60 lines (38 loc) · 3.9 KB

Using Git and GitHub

Git — source control system, repository — source code storage, GitHub — repository hosting.

First of all, it is recommended to download applications able to conveniently work with Git.

They learn how to commit individual lines of code instead of entire files and the principle of small commits (another article about microcommits).

image

What should I do if the entire file is displayed as changed?

image

  • Change the end-of-line format to another (for new files, prefer CRLF, but if the file is already in LF — do not change its format)
  • It is possible that there are spaces at the end of the lines (look for the trim whitespace function in the editor)
  • Tabs in the beginning of the lines changed to spaces (or vice versa)
  • The permissions of the file have changed, or its other properties
  • The file was moved

Git Special Files

image

  • .gitignore — indicates files or extensions for ignoring
  • .gitattributes — specifies the characteristics of file formats and endings of lines (usually just * text=auto)
  • .gitkeep — empty file, allows you to commit an empty folder
  • README.md — the file to be displayed in the web interface of GitHub when you go to the folder

How to issue and send a patch to the project?

The GitHub system uses the pull request mechanism — first a fork is created — a copy of the repository — commits are made to it, and then the merge request is sent to the original repository.

  • Click the Fork button at the top of the screen or select a specific file and click the pencil icon (this will also create a fork)
  • The Clone or download button in fork will download the repository for making changes
  • The New pull request button will create a merge/pull request — select the desired branch and target repository
  • A good description of the request — the key to mutual understanding. Do not break the code, do not use someone else's work without the right to do so and follow the style. New commits can still be made to the repository (no need to recreate the pull request or fork for this).
  • The repository administrator will hold a discussion and merge (or not)
  • After the merge, you can remove the fork

To update the fork code to the current version of the target repository — at this time, the easiest solution is to remove the fork and recreate it. The removal is done in the fork settings in its Settings -> Delete this repository -> Entering the name of the repository.

Receiving and sending changes

Git allows you to store commits locally on the computer (the commit itself does not cause sending to the server), and send at any convenient time.

  • git pull or consonant fetch operation in the editor — getting changes from the server
  • git push or consonant sync operation in the editor — sending changes to the server

What if the sending fails?

  • Check server availability
  • Make sure that you have write access to the repository or that it is not a someone else's repository
  • There may be conflicting changes, discuss them with the administrator of the repository

You can also make changes to the code or wiki pages editing via the GitHub web interface by selecting the file and clicking the pencil icon.

See also: