What is GitHub?
Microsoft has owned Github, the largest source code host in the world, since 2008. In essence, it greatly eases the usage of git for collaboration and version control by both individuals and teams.
Git and GitHub
Version control is used in it.
It records the modifications to your code.
Facilitate teamwork on large-scale initiatives
You can always go back to a previous version of the project.
View the project's complete history
TERMS
Git: is a distributed, open-source version-control system.
GitHub: It is a website where users may host and work together on Git repositories.
Commit: a Git object, a compressed SHA snapshot of your complete repository.
Branch: a portable, lightweight reference to a commit.
Clone: A local version of a repository that includes all commits and branches is called a "clone."
Remote: a coin repository on GitHub that all team members use to exchange their changes.
Fork: a replica of a GitHub repository controlled by a separate user.
Pull Request: Review, comment, integrated tests, and other features may all be found in a pull request, which is a location to compare and debate changes made to a branch.
HEAD: the HEAD pointer can be shifted to various branches, tags, or commits when using git switch. It represents your current working directory.
Central vs Remote Repositories
A connected keyboard to a computer is local to that computer, the same as a local repository is on the local system.
Similar to local repositories, remote repositories are those that are situated on a system that is not the same as the local machine.
The majority of machines typically have remote access to a central repository, but all of those machines have access to the same remote repository. An example of a central repository that everyone working on a project may use to communicate with others on the same project is GitHub.
Because they offer a rapid and economical approach to reaching agreement on the present status of a distributed graph of repositories, central repositories are advantageous.
Clone vs Fork
CLONE | FORK |
Cloning is done using Git | Forking is done on the GitHub Account |
Cloning a repository creates a copy of the original repository on our local machine | Forking a repository creates a copy of the original repository on our GitHub account |
Changes made to the cloned repository cannot be merged with the original repository unless you are the collaborator or the owner of the repository | Changes made to the forked repository can be merged with the original repository via a pull request |
Cloning is a process | Forking is a concept |
Cloning is done through the command ‘git clone 'and it is a process of receiving all the code files to the local machine | Forking is just containing a separate copy of the repository and there is no command involved |
Configure Tooling
Configure user information for all local repositories
Sets the name you want to be attached to your commit transactions
$ git config --global user.name "[name]"
Sets the email you want to be attached to your commit transactions
$ git config --global user.email "[email address]"
To check the config
git config --get user.email git config --get user.name
- global is used to set it permanently
CREATE REPOSITORIES
You have the option of cloning an existing repository or creating a new one locally. A repository must be pushed to GitHub after being initially created locally.
$ git init - The git init command turns an existing directory into a new Git repository inside the folder you are running this command.
After executing the git init command, use the following command to link the local repository to an empty GitHub repository:
$ git add origin remote [url]
Names the remote repository that will be used by your local repository. The link directs users to a GitHub repository. $ git clone [url]
Clone (download) an existing repository from GitHub with all of the files, branches, and commits.
Steps to make changes in the Public Repositories
Fork the repo which u want to edit
Copy the link of the repo for cloning
Clone it using the CLI (git clone)
Then u can make changes in the repo using any editor
You can use the git status command for checking purposes that your update is done or not
Create a new branch using (git checkout -b "branch name")
Add the file in which you did the changes (git add "file name")
Commit it with a message (git commit -m "your message")
Then at last push the file (git push origin "branch name")