Github is a distributed version control system that helps developers manage different versions of project files. In a distributed system, you can copy a complete repository (ie git, project) with its entire history to any machine making it easy to work remotely on projects from any physical location.
Developers utilize Git via commands that are delivered via the console which grants access to a repository. You can edit your files, then run Git commands to store your changes. Each time you complete a change to a project file, Git records a snapshot of their current contents. These snapshots are known as commits which are pushed back to the repository and stored.
This section includes a list of commands along with the circumstance that would require you to use each.
Git Commands include 'Options' that can be specified with a Single dash (-) or a Double dash (--) followed by a Letter or a Word, respectively.
There are two ways to create a repository: You can Clone a repo from another machine, or you can Initialize a brand new repo.
remote add origin+
At this point, you have a repository properly configured and you simply want to save your work. Before saving your work, you run [Step 1] to ascertain what files are ready to be versioned.
commit -m "Description"
push -u origin master
After performing these four steps, you will be promted to enter your credentials unless you use advanced features that allow you to configure your dev environment.
To view how a file was modified, use the
--staged) to make comparisons. Files that have been modified will display
- while files that have been removed will display
When writting commits, have fun including Emojis!
Below are commands that may prove useful only after becoming comfortable using the console.
rm file1.ext file2.ext file3.ext
mv "oldFilename.ext newFilname.ext"
reset HEAD^ filename.ext
revert SHA ID#
git log command produces a list of Commits along with their Simple Hashing Algorithm (SHM) identification number, which is a checksum of all changes in that commit. The checksum is the result of combining all the changes in the commit and feeding them to an algorithm that generates these 40-character strings. When you need to select a commit from your history, you can use these SHA-1 checksums, or "SHAs" for short, to identify which commit you want.
Using github for independent projects is slightly different when working with others. For starters, a repo that you own is called a Local Repo whilst a repo owned by another developer is called a Remote Repo. Each repository is a full copy of its original, including version history.
While developers can make commits to their own repo independent of others, a dev must always pull commits other developers have made from a remote repo to a local repo to maintain the most up-to-date version.
remote add origin+
remote(Default Remote Name is 'origin')
pull origin(Add Updated Files to Directory)
Collaborators typically use a declared central repository and gain acces via cloning into their local machine. This allows developers to work on different components that can be added to the central repo by pushing commits. Simply add the repo by name to the folder on your local machine.Last Updated: 3/20/2019