Skip to content

Instantly share code, notes, and snippets.

@itsJarrett
Created December 5, 2018 00:12
Show Gist options
  • Save itsJarrett/d2b38502abba02fa08c0a383f47a9c49 to your computer and use it in GitHub Desktop.
Save itsJarrett/d2b38502abba02fa08c0a383f47a9c49 to your computer and use it in GitHub Desktop.
Git Explanation

Explaining git concepts

git

Git is a version control system used for tracking changes to files.

Initializing a git repository

To utilize the git version control system, one must first initialize a repository; a repository can be initialize by the command git init in your git console. To ensure a file is being tracked by git, one must add files to the repository by the command git add <FILENAME HERE>, this will stage the file in the current working branch.

Branching

Branches are used to develop changes to the files isolated from each other. The master branch is the "default" branch when you create a repository. Use other branches for development and merge them back to the master branch upon completion. To create a new branch utilize the command git checkout -b <BRANCH NAME HERE>, and to switch back to the master branch, utilize the command git checkout master.

Commit'ing

Git can tell when a file is modified and show the changes via the command git status once the file has been staged. To store a change to the repository, one must commit the changes. This can be done via the command git commit -m "<MESSAGE ABOUT CHANGES HERE>".

Repository Collaboration

Git can be used to coordinate work on those files by using a remote repository by utilizing a site such as http://GitHub.com. To make your local git repository remote, you must add the remote origin by utilizing the command git remote add origin <URL TO REMOTE REPOSITORY> in your git console. Be weary when working with a remote repository, a branch is not available to others unless you push the branch to your remote repository by utilizing the command git push origin <BRANCH NAME HERE>.

Merge Conflicts

Sometimes multiple people may try to edit the same content. If one tries to edit code that someone else is editing, a merge conflict may occur. To alleviate the occurrence of conflicts work should be done in separate isolated branches. The most direct way to resolve a merge conflict is to edit the conflicted file. Open the merge.txt file in a text editor, and review the conflicts, and erase the changes that are not needed; keep the ones that are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment