Getting Started with Github
By Tisha Chawla
What is Github?
GitHub is a web-based version-control interface and collaboration platform for software developers. It allows developers to collaborate on a project more efficiently by providing tools to work together to build and edit their site content. An analogy of Github could be of a social networking site where members can follow each other, rate each other’s work, receive updates for specific projects, and communicate publicly or privately.
Now that you have understood what Github is, Let’s talk about the three most important terms used by developers in GitHub.
Fork: A fork is a copy of a repository that you manage. Forks let you make changes to a project without affecting the original repository. You can fetch updates from or submit changes to the original repository with pull requests.
Pull request: Pull requests let you tell others about changes you’ve pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.
Merge: Git merge will combine multiple sequences of commits into one unified history. In the most frequent use cases, git merge is used to combine two branches. It is Git’s way of putting a forked history back together again.
How Do I Speak GitHub?
Branch : A branch represents an independent line of development. Branches serve as an abstraction for the edit/stage/commit process discussed in Git Basics.
Repository (repo) : It is a folder in which all files and their version histories are stored.
Markdown (.md) : It is a way to write in Github that converts plain text to GitHub code. Sites such as Atom and Sublime Text are examples of free resources for developers using Markdown.
Commit Changes : It is a saved record of a change made to a file within the repo.
Version Control : A system that records changes to a file or set of files over time so that you can recall specific versions later.
- Other products and features include:
Github Gist allows GitHub users to share pieces of code or other notes.
GitHub Flow is a lightweight, branch-based workflow for regularly updated deployments.
GitHub Pages are static web pages to host a project, pulling information directly from an individual’s or organization’s GitHub repository.
GitHub Desktop enables users to access GitHub from Windows or Mac desktops, rather than going to GitHub’s website.
GitHub Student Developer Pack is a free offering of developer tools that is limited to students and includes cloud resources, programming tools, and support, and GitHub access.
Having learned the basics of Github, it’s time to move on to git commands.
git init
Usage: git init [repository name]
This command is used to start a new repository.
git clone
Usage: git clone [url]
This command is used to obtain a repository from an existing URL.
git add
Usage: git add [file]
This command adds a file to the staging area.
git commit
Usage: git commit -m “[ Type in the commit message]”
This command records or snapshots the file permanently in the version history.
git diff
Usage: git diff
This command shows the file differences which are not yet staged.
git reset
Usage: git reset [file]
This command unstaged the file, but it preserves the file contents.
git status
Usage: git status
This command lists all the files that have to be committed.
git rm
Usage: git rm [file]
This command deletes the file from your working directory and stages the deletion.
git log
Usage: git log
This command is used to list the version history for the current branch.
git branch
Usage: git branch
This command lists all the local branches in the current repository.
git merge
Usage: git merge [branch name]
This command merges the specified branch’s history into the current branch.
git push
Usage: git push [variable name] master
This command sends the committed changes of the master branch to your remote repository.
Usage: git push [variable name] [branch]
This command sends the branch commits to your remote repository.
git pull
Usage: git pull [Repository Link]
This command fetches and merges changes on the remote server to your working directory.
- Resources :
https://digital.gov/resources/an-introduction-github/
https://searchitoperations.techtarget.com/definition/GitHub
https://docs.github.com/en/github/collaborating-with-pull-requests/working-with-forks
https://www.atlassian.com/git/tutorials/using-branches/git-merge
https://www.atlassian.com/git/glossary/terminology
https://dzone.com/articles/top-20-git-commands-with-examples