fullstack_webdev

Code and notes from Full stack web developer path, LinkedIn Learning.

View on GitHub

5. Git Essential Training

0. Introduction


1. What is Git?

01_01 Version Control

01_02 The history behind Git

  1. SCCS: Source Code Control System, released in 1972 and was developed by AT&T and it was bundled free with the unix operating system. Unix was also free and as a result unix spread quickly to universities and SCCS went along with it. Unis taught their students how to do version control using SCCS, so when they left the uni to go work in jobs, the VCS they were familiar with and they took with them was SCCS. So that’s why it became really popular.

SCCS stayed dominant until the early 80s when RCS Revision Control system came in.

  1. RCS: Revision control system made lots of improvements over SCCS. RCS was cross-platform whereas SCCS was unix only. With the rise of personal computer it was important to have a VCS that would also work on PCs. RCS was more intuitive, had a cleaner syntax with fewer commands and more features. Most importantly, it was faster and a lot of the speed increase came from the fact that it used a smarter storage strategy than SCCS.
  1. CVS: Came up in 1986-90. Concurrent Version System allowed you to keep track of sets of files. CVS had made a lot of innovative stride forward. It was open source, had tracking support for multiple files, entire project.
  1. Apache SVN: Apache Subversion came out in 2000. It was faster than CVS and allowed saving of non-text files like images which CVS couldn’t do. SVN was tracking not just changes to single files or to group of files but actually watching what happened in a directory as a whole and taking snapshot of a directory.
  1. BitKeeper SCM: Came out in 2000, closed source, proprietary source code management tool. One of the features that BitKeeper had was distributed version control. Being closed source whereas all the other VCS we saw were open sourced, what does that mean ? BitKeeper had a community version and this was free, had few less features and some usage restrictions. There was a paid version of BitKeeper and free one called community version.

Git is born

01_03 About Distributed Version Control


02. Install Git and Basic Configuration

System
git config --system

User
git config --global

Project
git config
git config --global user.name "AnmolTomer"
git config --global user.email "email@domain.com"
git config --global core.editor "C:\\Program Files\\Microsoft VS Code\\Code.exe" --wait
git config --global color.ui true
# Edit ~/.bashrc or ~/.bash_profile
if [-f ~/.git-completion.bash]; then
    source ~/.git-completion.bash
fi

# If the file exists load it into the memory.

03. Getting Started


04. Git Concepts and Architecture

05. Make Changes to files

Which of these methods is best to deal with a file called this_file.txt that should not be deleted but should no longer be referenced when git status is used?

How is staging an edited file different from staging a new file?

If the output of git status reveals that file file1.php is untracked, what is true about the file?

If a user must use git reset HEAD tabs.js to unstage tabs.js, which command likely created the need to reset the HEAD?

The output of git status is the following text, the last line in green: Changes to be committed: Which action did not create this result?

(use "git reset HEAD <file>..." to unstage)

deleted: file1.php

How does committing an edited file affect the Git architecture’s trees?

What is the most efficient way to rename a file in a repository?

In which situation should you use git diff?


06. Working on a real project


07. Undo Changes

What is the difference between git reset HEAD header.c and git checkout -- header.c?

Which command will replace the staging directory version “footer.css” with the repository version?

What is the output for the final command if file1.c is staged and file2.c is untracked? git clean -f git reset HEAD -- file1.c git clean -n

What is the result of the following commands if file1.c, file2.c, and file3.c are untracked? git add file2.c git clean -f

You have found a commit message three generations back, with SHA fdda5e3d8, is poorly written. Which use of git commit --amend will allow you to edit the commit message for that commit?

You have made significant changes to your working directory, editing file1.c, file2.c, and file3.c. You also made changes to the inc/ directory and staged those changes for commit. Now you want to roll everything back and undo all changes. Which should you use?

Assuming the SHA of HEAD’s parent commit is 9812aa1b, what is the result of git revert 9812aa1b?

Which command will allow a user to preview a list of only untracked files to be deleted?

Which use of git commit --amend is not allowed?

A client has decided they want to revert one page of their website generated by about.php to a version they had in the commit with SHA 53daff9b. Which process should you use?


08. Ignore Files

What steps can a user take to remove a personal file from the repository while keeping a local copy that won’t be tracked by Git?

Why might packaging and distribution files and directories be included in a .gitignore template?

Using git status reveals Git does not see the directory “css”. What steps can you take to troubleshoot?

Which of these should not generally be included in the .gitignore file?

What is the conventional file name to ensure an otherwise empty directory is included in the repository?

Why might a user choose not to include a .gitignore file in the repository?

After adding a file to your .gitignore, you type git status and see the file listed as untracked. Why is the .gitignore inclusion not successful?

Which types of files should always be globally ignored?

Which kind of file might be included in the file generated by this command: git config --global core.excludesfile ./.gitignore_user