Committing Atomic Changes Flashcards
What is version control?
Version control or source code management tools or revision control system take on the task of keeping a software system consisting of many versions and configurations well organized. Version control tracks every iteration of your product or application, basically a log of your history and versions of software.
How to install git?
- ) To install git simply run $ sudo dnf install git-all.
- ) Set the username to identify your repository $ gitconfig - -global user.mail myemailaddress@aol.com
- ) You may want to set the editor you’ll be working in $ git config - -global core.editor “subl” -w
- ) You may want to set some coloe to your interface. Run $ git config - -global color.ui true.
If git is installed how would you go about creating a new repository on your computer?
Create a new folder and inside the folder run $ git init.
Inside every repo you create there’s an invisible .git folder that’s developed. What kind of files might you see if you opened that .git folder?
You should see HEAD, config, hooks, objects, branches, description, info, refs. Each file is critical to know and be familiar with if you want to master git.
Most version control systems have 2 tree architectures: a working directory and a repository. What about Git?
Git has a 3 tree architecture: working directory, staging index, repository. Think of the workking directory as the work on your local computer.
When you go through with a commit one of the major things the computer does with your commit is to assign what to your commit?
Git gives that commit a checksum #. The top of your commit chain will always have a HEAD pointer indicating the most recent commit or a pointer to the current branch reference. This reference later becomes a pointer to the proceeding/new branch.
What command would you run to see your commit history?
$ git log
What command would you run to show the difference between the last commit and a recent commit?
$ git diff
What would $ git diff - -staged do?
git diff - -staged will show you only the changes made to the files in the staging index.
What command do you use to remove a file from your repo?
$ git rm file.txt
How do you rename a file in your repository?
$ git mv firstName.txt newName.txt
How would you go about undoing changes on a branch after you’ve just written new code and want to revert back to the old code?
$ git checkout. This pulls your latest commit and ignores any changes you have in your working directory.
$ git checkout would pull your branch and allow you to start working on it.
How do you unstage things?
$ git reset or $ git reset HEAD ( both of these reset staging to the last commit ), just after you add a file to the staging index, if you added the file already reset would not work.
How to amend your last commit message?
https://www.atlassian.com/git/tutorials/rewriting-history
$ git commit ammend -m “this is an updated commit”
How do you define a git alias?
$ git config - -global alias. ;
$ git config - -global alias.unstage ‘reset HEAD –’
$ git config - -global alias.civ ‘commit -v’;
$ git config - -global alias.ci commit
$ git config - -global alias.st status;