Blog 0 - Git
Introduction to Git
What is Git? Git is a piece of software that allows you to track changes in any set of files. It's typically used to coordinate work among programmers who are working on source code together throughout the creation of software. Speed, data integrity, and support for dispersed, non-linear workflows are among the objectives.
Introduction to GitHub
Now, what is GitHub? And what is it used for? GitHub, Inc. is an Internet hosting company that specializes on Git-based software development and version control. It includes Git's distributed version control and source code management functions, as well as its own.
Git Commands
For this class we learned a number of git commands, which also happen to be the commonly used commands for git.
git status shows the current state of the working directory.
git add adds modifications made to the staging area from the working directory.
git commit is the command that captures a snapshot of the project's currently staged changes, and we usually want to append it with -m to add a comment afterwards, which will then show up on GitHub with the file. You usually want the comment to be a brief description of the changes you made to the file.
git push is the command that is used to upload your local repository to a remote repository, which in this case basically means from your personal terminal to somewhere like GitHub.
These set of commands are usually the process you would follow to push over new code into GitHub. You normally want to do a git status just to make sure that the changes pop up, then a git branch, which I will talk about in the next set of commands, and then follow it up with git add ., git commit -m "comment here", and git push.
These next set of commands are usually what you want to perform when starting on a new project, or when making edits to current files you have.
- git branch will display the current branch you are in and also the other branches that you have on your system, or working directory.
- git checkout -b is the command used when making a new branch. Normally, after the -b you will want to put the name of the branch you wish to make. You normally do not want to add spaces to branch names. It is best to append them with a -
- git pull is used to get the new information that has been loaded into the repository you are working from, but normally you want to do this when you are on main/master to add all new information that has been pushed.
- git branch -d is the command that is used when deleting branches. You normally want to do this to have a clean directory, but only delete the branch after you have merged your changes to GitHub and pulled from main.
- git checkout is the command that is used when switching between branches, as you would follow it with the branch name after that command.