Difference between revisions of "GIT"

From emboxit
Jump to: navigation, search
 
m (1 revision)
 
(No difference)

Latest revision as of 16:51, 11 September 2015

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

GIT Areas

  • Working directory is where we modify our files
  • Staging Area is intermediate area that shows which files we will be saved in our local database with our next commit
  • Git directory (repository) are files that are committed (safely stored in the local database)

Modified are changed files but havent been committed to the database yet.

IMPORTANT INFORMATION

Git seems that does not track empty directories. So if you want to create a directory structure you MUST add files in the directories

GIT Bash

All information below are relevant to the git bash and not any graphic interface.

Configuration

  • /etc/gitconfig configuration values for every user
  • /.gitconfig configuration values for a specific user.
  • .git/config configuration values for a specific repository.

The above can be configured through the command git config --system

  • Configure username: git config --global user.name "Kostas Anagnostopoulos"
  • Configure email: git config -- global user.email kostas.anagnostopoulos@cit.ie

Create a .gitignore file to include any file that must not be included in the git process.

Usual Commands

  • Initialise directory: git init directory name
  • Add files to staging area: git add filename
  • Add all files to staging area: git add .
  • Commit: git commit -m "Message with the commit"
  • Shows changes to files : git status
  • Copy an existing directory: git clone [url] directory_name
  • Remove tracked files and remove them from the directory: git rm filename
  • Don't track file but keep it in the directory: git rm --cached filename
  • Rename file:git mv file_from file_to
  • Show log of commits: git log
  • Change your last commit: git commit --amend
  • To unstage a file (it is written in the git status message): git reset HEAD filename
  • Unmodify a modified file (it is written in the git status message): git checkout -- filename
  • Add a remote directory: git remote add designation_name pat_to_remote_directory
  • Get updates from remote project(it doesnt merge automatically): git fetch designation_name
  • Push updates to remote project (check below from branch): git push designation_name branch_name

Branches

Branch means you diverge from the main line of development and continue to work without messing with that main line.

  • Create branch: git branch branch_name
  • Show existing branches: git branch
  • Switch to branch: git checkout branch_name
  • Merge branch to the current worsking version: git merge branch_name
  • Delete branch: git branch -d branch_name

Tags

TODO