Definition of Git and GitHub:
Git is an open-source version control system and an important tool for tracking changes of specific files locally, whereas Github works along with Git and allows users to work collaboratively over a variety of pieces of code to build projects from anywhere around the world and the modifications or deploys are stored directly in a remote repository.
Supposing that your git and github account are completely synchronized, I’m going to show how to interact with both platforms.
Git commands to startup:
git init | Initializes a new repository withing the specified directory.
git config –global user.‘Name’ | In order to be identified we use this command.
git config –global user.‘[email protected]’ | To identify your personal email we usr this command.
git status | Allows the user to check any modifications and shows the files that can be either added or commited to the staging area.
git add | Adds the modified files to the staging area, meaning that the staged files are ready to be committed.
git commit -m “Comment” | This command commits the staged files to the commit history, this creates snapshots that help the users to have saved versions in case they want to roll back to any outdated version.
git commit -am “Comment” | In order to add and commit a file directly we use the flag -am.
git log | Displays the commits made previously with a unique hash number along with the time, author, and name of change.
git diff | Displays the last and current modification.
git restore “fileName” | Undo modifications.
git push | This command is essential after committing our changes, it will update the remote repository with our modified files
git clone [repository url] | This git command clones completely the specified forked repository, however, it will not belong to you, if you would wan to contribute to the owner’s respitory you could do a “pull request” over the owne’s remote repository on github.
git pull -r | Updates the cloned repository.
git checkout -b branchname | This creates a new branch besides the master branch which is the main one.
git checkout branchname | Used to switch to existent branches
git branch | To see al the existent branches.
git checkout -d branchname | Deletes the branch created previously.
git fetch origin master | Upates the git working terminal with the repository modifications, however, the changes are not downloaded directly, they are just maintained in standby until [git merge] is executed afterwards.
git rebase branchname | Command used to update the branch you are currently in with the branch you specified.