Put simply it is the practice of tracking and managing changes made to software. It allows us as developers to jump into a project and instantly get an understanding on where the project is going and where it has been without having to search too many documents and files.
Git is a popular Version Control System (VCS), it is distributed, so it is local to the user's hardware. Git is a program
that when downloaded and ran can be used to track and manage changes to files and directories.
How Git operates is what makes it so popular. Git takes snapshots of a project or folder and saves the changed files whilst
linking the other files to their previous versions. If I was to have 3 files in Git after updating file A Git would track
the change to file A and then copy the data from the previous version of file B and C.
Other VCSs just trak the changes made to the project.
There are three stages in Git, Modify Staged and Commit.
Projects are on the shelf, if you were to commit now nothing would be saved. These files have been modified but the change won't affect produce a new version
These files have been changed and if committed Git would produce a new version. It's almost like putting a file into a shopping cart, it hasn't been purchased, but it is not on the shelf anymore.
A snapshot is taken of the folder profile, and it is saved into a repository.
git initThis creates a git repository in the corresponding directorygit statusThis shows which files/ folders are staged (ready to be committed)git addThis adds a file/folder to the stage (ready to be committed)git commit -mThis commits the staged files/folders to the git repo.gitignoreThis creates a folder that hides other folders from git status
git logShows the commit history to the corresponding repositorygit diffHelps me see, compare and understand changes between different commits
Diagram 1
Diagram 2
Diagram 1 shows the link between users and Git, a local repository. Diagram 2 shows the link between local repositories and GitHub a cloud based repository. With a local repo everyone connected dumps their files into one repo which can lead to problems when people commit at the same time. The benefits of a cloud based repo or a distributed version control is that users can simultaneously commit their files and projects without there being a problem because they are independently committed.
- GitHub
GitHub is a could based distributed version control, it doesn't require every user link to a repo via hardware (locally). Github does have a few competitors such as Bitbucket and GitLab and others.
GitHub gives clear commands to type into GitBash as listed below
git remote add origin https://github.com/temianibaba/tech258_git.git
git branch -M main
git push -u origin main
- When you haven't initialised a local repo
echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/temianibaba/test.git
git push -u origin main
git branch #(name branch)
git checkout #(name branch) - moves to new branch
git branch -d #branch_name - delete branch



