The whole repository is available locally. So version history is a local call.
Files are stored as hash value of the files contents rather the name of the file.
Data is never delete, git only adds to the repository. This makes it easy to go back in history.
Files have been modified and git had nothing to do with the changes.
Files have been marked so the changes will go into git.
Safely stored in the git repository
Some commands can only be run on command line. They are installed on every system that has git.
git config --list --show-origin
git config --global user.name "Dharam Veer"
git config --global user.email dharam@kuru.com
git config --global core.editor emacs
git config --global init.defaultBranch main
get help <verb>
git <verb> --help
#git, #github, or #gitlab
git add -h
git init
git clone <repo location>
The tracked
files are the files that Git knows about, the rest are untracked
files.
See the current status of files git status
Create a file called README
with some data in it echo data > README
.
To track this new files git add README
Even for staging modified files, we use the same git add A
Get concise short status using git status -s
.
??
untracked files
A
staged files
M
modified files
First column -> Staging Area
Second colum -> Working tree
Glob patterns are simplified regular expressions that shells use.
*
: zero or more characters.
[abc]
: Matches any character inside the brackets
?
: Matches a single character
[0-9]
: Matches Any character between zero and 9
a/**/z
: Matches nested directories.
Some examples
.gitignore
# ignore all .a files
*.a
# but do track lib.a, even though you're ignoring .a files above
!lib.a
# only ignore the TODO file in the current directory, not subdir/TODO
/TODO
# ignore all files in any directory named build
build/
# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt
# ignore all .pdf files in the doc/ directory and any of its subdirectories
doc/**/*.pdf
We can use git diff
to see either
- What has been committed or
- What has been staged and ready to be committed, .
You can see what has been committed by just git diff
.
And, what has been staged and ready to be committed, by doing the following git diff --staged
or git diff --cached
commands.
You can then commit your changes by using git commit
.
To save information about what changes you have made to your repository, you can use git commit -v
.