- Repository -> Folder under version control
- Commit -> unit of work
- Clone -> a copy of the work
- Trunk -> Main line of work
- Branch -> Separate line of work, thought, or experimentation
- Marge-> Process of get a branch back to the truck
- Tag -> Mark a particular spot in the work
GIT has an architecture of three-trees: repository tree, stage tree, and the working tree.
add
command moves files from working tree to stage tree.
commit
command moves file from stage area to the repository.
- SHOW GIT CONFIG INFO
> git config --list
- CHECK USER NAME
> git config user.name
- CHANGE USENAME
> git config --global user.name "Jaime Bohorquez-Ballen"
- CHECK USER EMAIL
> git config user.email
- CHANGE USER EMAIL
git config --global user.email [your email address here]
- GITHUB CONFIG FILE
~/.gitconfig
- CLONE EXISTING REPOSITORY ON GITHUB:
> git clone URL
- CREATE A LOCAL REPO
> git init
- STATUS REPO:
> git status
- VIEW CHANGES:
> git diff
- VIEW CHANGES IN STAGE AREA:
> git diff --staged
OR> git diff --cached
- ADD CHANGES TO FILE
> git add file_name
- ADD EVERYTHING
> git add .
- REMOVE FILE:<br>
> git rm file_name
- RENAME FILE:
> git mv old_name new_name
- COMMIT
> git commit -m 'description'
- COMMIT WITH NO ADDING:
> git commit -a
OR> git commit --all
-COMMIT ALL WITH MESSAGE:
> git commit -am 'Mesagge'
- UNDO IN WORKING DIRECTORY:
> git checkout -- file_name
- UNSTAGE FILES:
> git reset HEAD file_name
- AMEND COMMITS:
> git commit --amend -m 'message'
- RETRIVE OLD VERSIONS:
> git checkout sha1-commit-number -- file_name
Note: sha1-number can be access throughgit log
-REVERT A COMMIT:
> git revert sha1-number
- REMOVE UNTRACKED FILES:
> git clean -n
andgit clean -f
- SEND CHANGES TO GITHUB REPOSITORY
> git push
gitignore file can have: regular expressions, # for comments.
cat .gitignore
# file name to be ignore by git
file_name
gitignore file for especific applications can be found at github.com/github/gitignore.
Global ignore files are done by
> git config --global core.excludes ~/.gitignore_global
Ignore stged files:
- Add file2ignore to .gitignore
git add .gitignore
git rm --cached file2ignore
git commit -m 'Stop tracking file2ingnore
- Short line summary
- Can be followed by a blank line and a more complete description
- lines with less than 72 characters long
- Present tense
- View commit log
> git log
- Specific string on log
> git log --grep='regular_expresion'
git does not track empty directories. If you want to track them, add a file .gitkeep
at the directory you want to keep.
> touch directory2keep/.gitkeep