4.GitHub (in English) - YukaKoshiba/MyknowledgeDocs GitHub Wiki
GitHub @English Version
Create Date:2024/05/14
Last Update Date:2024/08/21
- a version control system
- A comprehensive tool for tracking code changes(Who made the changes, Where they were made, and Why) When a file is changed, added or deleted, it is considered modified.
- It's used to collaborate on code.
- Git and GitHub are different things.
- It was created by Linus Torvalds in 2005, and has been maintained by Junio Hamano since then.
- Branches allow you to work on different parts of a project without impacting the main branch.
- We can even switch between branches and work on different projects without them interfering with each other.
- Branching in Git is very lightweight and fast.
- Developers can view the complete project history.
- Developers can revert to previous versions of a project.
- Over 70% of software developers worldwide use Git.
- Developers can collaborate seamlessly from anywhere in the world.
- Commit
One of the core functions of Git
Adding commits allows us to track our progress and changes as we work.
Git considers each commit a change point or save point.
It serves as a reference point in the project that we can return to if we encounter a bug or want to make a change.
We should always include a clear and concise commit message with every change to make it easier for developers to understand the changes made. - repository
- Staging Environment
One of the core functions of Git
A staging environment for final checks before deployment, accessible to clients for review. - Branch
Comprehensive change history tracking with branching
Developers can freely modify branches without impacting other branches in the same repository.
Furthermore, multiple branches can be seamlessly merged into a single branch.
Branches are maintained as immutable snapshots, rather than change deltas or diff data.
Branching in Git is very lightweight and fast.
A Git repository can contain multiple branches, but a developer can only work on one branch at a time.
| Branch types | Explanation |
|---|---|
| master branch | The default branch created by Git The branch committed software that is complete, bug-free, and functional. Developers should avoid making direct changes to the source code in the master branch. Deletion will never be possible it. |
| develop branch | The core branch for software development When a new repository is created, the develop branch is initially created from the master branch. During software development, developers repeatedly merge changes from related feature branches into the develop branch. Developers should avoid making direct changes to the source code in the develop branch. Deletion will never be possible it. |
| feature/new-feature branchd |
| input Command | output | remarks | |
|---|---|---|---|
| Checking my installed Git version | git --version |
git version 2.42.0.windows.2 | |
| Updating my installed Git version to the latest version |
git update-git-for-windows(If you are asked whether to update or not, type "y".) |
Updating your Git to the latest version | Above is the command when the OS is Windows MacOS: brew upgrade gitLinux OS: sudo apt-get install git
|
| Initialize Git on the current folder | |||
| Creating Git New Folder | mkdir NewFolderName |
- | |
| Changing the current working directory | cd FolderName |
Changing current puth | |
| Initialize Git | git init |
Initialized empty Git repository in [CurrentFolderpath].git/ | |
| Listing files in the current directory | ls |
A list of filenames is displayed. | |
| Checking the Git status | git status |
Either of the two states is displayed. *Tracked -files that Git knows about and are added to the repository *Untracked -files that are in my working directory, but not added to the repository |
option --short: Display a more concise status summary. (flags: ??-Untracked files, A-Added files, M-Modified files, D-Deleted files) |
| Staging a specific file for commit | git add FileName |
- | To stage all files in the current directory for commit, use "git add --all" or "git add -A" instead of FileName. |
| Commit changes to the repository from stage | git commit -m "My message" |
We should always include a message with every commit. | |
| Commit changes to the repository directly without staging | git commit -a -m "My message" |
a Git commit log | Basically non-recommended |
| Creating New branch | git branch "BranchName" |
- | |
| List of Branches in the Current Repository | git branch |
Branches currently working | The asterisk (*) indicates the currently active branch. |
| Move the branch to be worked on | git checkout "Branch name to move to" |
option -b: Create and move the new branche |
|
| Merge two branchs | git merge "a merged branch name" |
We need to switch to the base branch before merging | |
| Delete a branch | git merge "a merged branch name" |
We need to switch to the base branch before merging | |
| View the Git commit history | git log |
a Git commit log | |
| Setting the user name for the current repository | git config user.name "UserName" |
- | |
| Setting the global user name | git config --global user.name "My user name" |
- | Always in Roman alphabet |
| Setting the global user name | git config --global user.email "[email protected]" |
- | |
| Setting the command color | git config --global color.ui auto |
- | Makes commands easier to read *Optional |
| View options for a specific command | git [SpecificCommand] -help |
a Git Help about the specific command | |
| View all available commands | git help --all |
The complete Git help documentation | To exit the extended list, press SHIFT + G and then q. |
- Open-source software
- A hosting service for Git repositories
- Enables you to share software code with your friends and other software engineers worldwide.
- A comprehensive tool for tracking code changes(Who made the changes, Where they were made, and Why)
- GitHub is the world's largest host of source code and has been owned by Microsoft since 2018.
- GitHub is not the same as Git. Git is a distributed version control system, while GitHub is a hosting service for Git repositories.
- GitHub provides tools that use Git.
Refer to GitHub official website
* W3schools* GitDocumentation
* GitHub実践入門 Pull Requestによる開発の変革 大塚弘記
*@IT