You are on page 1of 6

Contents

I.1 Configuration..........................................................................................................................................2
I.2 Auto completion.................................................................................................................................3
I.3 Help....................................................................................................................................................3
II.1 Initialize a repository.............................................................................................................................4
II. 2 Storage..............................................................................................................................................4
II.3 Commit..............................................................................................................................................4
II.4 Commit message...............................................................................................................................5
II.4 View the commit log..........................................................................................................................5
II.5 Arhitecture- the three trees..............................................................................................................5
III. Adding files.............................................................................................................................................6
I.1 Configuration
git –version
Using any Git command after installation will confirm Git is installed, but requesting the current
version of the tool is an easy way to confirm with minimal output and no need to set up a
repository.
Install on Mac:
Use the Ctrl key while clicking and then choose "Open with installer."
Install Git with the terminal utility command install git.
Hint: The Git installer at git-scm.com will install Git on a Mac.
Other configs:
a) System: /etc/gitconfig Program Files\Git\etc\gitconfig
b) User: ~/,gitconfig $HOME\.gitconfig
c) Project my_project/.git/config
Global configurations:
- mihai$ git config --global user.name “”
- mihai$ git config --global user.email “”
git config –list
Single configuration:
Mihai$ git config user.name
Mihai$ git config user.mail
IDE configuration:
git config
Git config with no options will access the project-level config file.

Mihai$ git config –global core.editor “notepad.exe”


Mihai$ cat .gitconfig
Color config:
git config --global color.ui false
Git's color.ui configuration is by default set to "auto", so it colorizes output to help users visually
parse the output quickly, except when output is piped or redirected to a file. To turn colors off,
you need only set color.ui to false for all output.
I.2 Auto completion
https://github.com/git/git

https://github.com/git/git/tree/master/contrib

https://github.com/git/git/tree/master/contrib/completion

or:

search completion

result:

https://github.com/git/git/blob/master/contrib/completion/git-completion.bash

copy by raw in IDE or save page as filename.bash

ad to .bash_profile

shell script:

if [ -f ~/.git-completion.bash] ; then

source ~/.git-completion.bash

fi

ctrl + X- Exit (close Window)

I.3 Help

Mihai$ git help


Mihai$ git help log

git help cherry-pick


man git-cherry-pick
The man page for git-cherry-pick is identical to the output from the git help cherry-pick
command, since the help command is essentially an interface for the git man pages.
II.1 Initialize a repository
git init
By not creating a directory for the repository and changing into that directory before typing git
init, all the home directory files and any sub-directories created will need to be included in an
ignore list for Git. Any new directory created in the home directory going forward will need to
be added to that list, as well.
git init initializes the directory with a .git directory containing project-specific files.
A deleted .git directory's contents cannot be recovered.
- create a directory, navigate with cd Documents/
mihai$ ls/ dir
cd nameFolder/
mihai$ ls
mihai$ git init
Ex.
git add . git commit -m "Initial commit" git add . git commit -m "Another commit"
Git will stage both files and commit them with the message "Initial commit." The next set of add
and commit messages will have no effect on the repository.
Feedback
git add . will stage all changed files in the repository, so the Initial commit will commit changes
to both edited files. The second set will not change anything, as there will be no changed files to
stage or commit.
Either the names of files to be added or a period (.) must be passed as an argument to git add so
git knows which files to stage.
II. 2 Storage

Mihai$ ls -la (from mihai$ pwd


/Users/mihai/Documents/filename)
Mihai$ ls -la .git (files of git)
Mihai$ cat .git/config (config infos)
II.3 Commit

- create a file with editor


mihai$ git add .
mihai$ git commit -m “message here”
II.4 Commit message
Rules:
- begin with a short single line summary of what the changes are (present tense, < 50
characters – max 72 characters per line- a label)
- message must be written in present tense,
- must give an overview of the change made in the commit
- stays within character limits, and does not include unnecessary information.
Ex: am adaugat linia lipsa in sectiunea de HTML a proiectului
II.4 View the commit log
- inside the project: mihai$ git log
mihai$ git help log (for help)
mihai$ git log -n 5(to limit the no of logs)
mihai$ git log –since= 2021-02-03 (past date)
mihai$ git log –until= 2021-02-03
git log --until=2020-09-10 -n 2(last two commits on sep 10 2020)
mihai$ git log –author=” jkfdlgj” (any part of the name)
mihai$ git log –grep=”regex” (globally searching for regex)
git log --since=2019-03-01 --until=2019-03-31 --author="Karen" --
grep="refactor" (The --since and --until narrow the date, --author defines
the commit's author, and --grep will search for all commits that include
"refactor" in the description.)
II.5 Arhitecture- the three trees

- 2 trees- repository and working copy( tree- file structure/ directory)


- 3 trees- rep/ copy- between staging index (2 step process [working copy]- git add file- [staging
index]- git commit file[repository])
- Hash Values: checksum for each change set (data conv to a simple number), unique and tied to
the value inside(SHA-1), 40 characters hexadecimals[0-9, a-f].
- Metadata: cannot change the commit message,parent or author of the commit
- Head: pointer, refers to a specific commit. Last commit, parent of the next commit.

If a bad actor tampers with a file in an old version of a repository, which is true?

the changed checksum would generate an error on access of that version or a


descendant.
Feedback
The hashing algorithm uses the commit ancestry to compute a SHA-1, so all
descendents of the altered commit would have invalid SHA-1 checksums.
III. Adding files

You might also like