Git
Git is a free and open source distributed version control system. Git's collaboration model gives every developer their own copy of the repository, complete with its own local history and branch structure.
Git is designed to give each developer an entirely isolated development environment. This means that information is not automatically passed back and forth between repositories. Instead, developers need to manually pull upstream commits into their local repository or manually push their local commits back up to the central repository.
Git tutorials Atlassian.com Git book documentation book git-scm.com
$ mkdir repo
$ cd repo
#create a file
$ touch file.php
to initialize a Git repository just cd into your project folder. git init creates a .git subdirectory in the project root.
$ git init
$ git status
git clone
command copies an existing Git repository.
$ git clone repo
working dir → staging (index) → .git dir (repository)
add commit
git add and git commit record versions of a project into the repository's history.
to tell Git to start tracking changes we first need to add it to the staging area.
#add the list of files
$ git add file.php file2.php
#add all files in current dir
$ git add *.php
the files listed here are in the Staging Area, and they are not in our repository yet.
To store our staged changes we run the
commit
command with a message.
Saved changes are called commits.
$ git commit -m "first commit hello"
$ git status
push pull
push
command will transfer commits
from your local repo to a remote repo (origin repo on GitHub).
the name of our remote is origin and the default local branch name is master.
$ git push -u origin master
we can check for changes on our GitHub repository and
pull
down any new changes.
$ git pull origin master
Git setup
[x] Windows Explorer integration [ ] Git bash here [ ] Git GUI here (x) use Git Bash only
$ git config --global user.name "Susie Smith"
$ git config --global user.email "susie@gmail.com"
$ git config --list
Git Immersion .com
setup line ending pref.
$ git config --global core.autocrlf input (Win: true instead of input)
$ git config --global core.safecrlf true