Github
Information about Git and GitHub
Difference between git and github
Summary
What is Git?
Git is a free and open source distributed version control system and is installed and maintained on your local system.
What is GitHub?
GitHub is a Git repository hosting service. GitHub allows you to keep track of and share your Git repositories outside of your local environment.
GitHub expands upon Git’s basic functionality with a simple user interface.
The simplest way to connect Git to GitHub and import repositories is by using the GitHub Desktop application
What's a version control system
Summary
A version control system tracks the history of changes.
- Which changes were made?
- Who made the changes?
- When were the changes made?
What's a repository?
A repository includes all files and folders associated with a project.
Github flow
- Branch
- commits
- Merge
If you would like to try out some new ideas create a new branch. Changes you make on a branch don’t affect the main branch.
Whenever you add, edit, or delete a file you’re making a commit, and adding them to your branch.
Each commit has an associated commit message, which is a scription explaining why a change was made.
Once you are done with your new feature you can merge your code into the main branch.
Git commands
Summary
There are specific commands to copy, create, change or combine code. These commands can be executed directly from the command line or by using an application like GitHub Desktop.
Basic Git commands
- git init
- git clone
- git branch
- git add
- git status
- git commit
- git merge
- git pull
- git push
initializes a brand new Git repository and begins tracking an existing directory. It adds a hidden subfolder within the existing directory that houses the internal data structure required for version control.
creates a local copy of a project that already exists remotely. The clone includes all the project’s files, history, and branches.
shows the branches being worked on locally.
stages a change. Git tracks changes to a developer’s codebase, but it’s necessary to stage and take a snapshot of the changes to include them in the project’s history. This command performs staging, the first part of that two-step process. Any changes that are staged will become a part of the next snapshot and a part of the project’s history. Staging and committing separately gives developers complete control over the history of their project without changing how they code and work.
shows the status of changes as untracked, modified, or staged.
saves the snapshot to the project history and completes the change-tracking process. In short, a commit functions like taking a photo. Anything that’s been staged with git add
will become a part of the snapshot with git commit
.
merges lines of development together. This command is typically used to combine changes made on two distinct branches. For example, a developer would merge when they want to combine changes from a feature branch into the main branch for deployment.
updates the local line of development with updates from its remote counterpart. Developers use this command if a teammate has made commits to a branch on a remote, and they would like to reflect those changes in their local environment.
updates the remote repository with any commits made locally to a branch.