Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Git ignore

Create .gitignore file and add following code as well as keep config file in GITIGNORE folder

# Hidden files
.*
._*
!.htaccess
!.gitignore

# Packages
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Adobe files to ignore
*.psd
*.ai

# Logs
*.log

# Compiled source
*.dll
*.exe
*.o
*.so

# OS generated files
*.lock
*.DS_Store
*.swp
*.out
ehthumbs.db
Thumbs.db

#Wordpress file
wp-config.php
wp-content/cache/*
wp-content/cache/supercache/*
wp-content/uploads/wpcf7_captcha/*.png
wp-content/uploads/wpcf7_captcha/*.txt
SOURCE/*
.idea/*

================
worpdress
#Wordpress file
wp-config.php
wp-content/cache/*
wp-content/cache/supercache/*
wp-content/uploads/wpcf7_captcha/*.png
wp-content/uploads/wpcf7_captcha/*.txt
SOURCE/*

GIT admin management

How to create a GIT user:

1.    Install GIT bash

2.    ssh-keygen -t rsa

3.    Collect id_rsa.pub file

4.    Open id_rsa.pub text editor and collect user name like “iman@BM-DEV-1”

5.    Rename “id_rsa.pub” file  name  to “iman@BM-DEV-1.pub

6.    Upload “iman@BM-DEV-1.pub” to server “gitosis-admin/keydir” folder

Assign user to specific GIT project

1.    Open File “gitosis-admin/gitosis.conf”  to text editor
2.    Members  =  iman@BM-DEV-1

Create new Git Project

Edit  "gitosis-admin/gitosis.conf" file and add thie following code
[group project_name]
writable = project_name
members = milon@BABA root@bakar.bitmascot.com iman@BM-DEV-19

Git questions and answers

http://career.guru99.com/top-40-interview-questions-on-git/

fetch vs pull
fetch will download any changes from the remote branch, updating your repository data, but leaving your local branch unchanged.

pull will perform a fetch and additionally merge the changes into your local branch.

Merge vs Rebase

  • Merge takes all the changes in one branch and merge them into another branch in one commit.
  • Rebase says I want the point at which I branched to move to a new starting point
A merge does not change the ancestry of commits. A rebase rewrites the ancestry of your local commits.

Git

Important Git command

GIT add all images

STEP 1:
git add **/*.jpg \*.jpg **/*.gif \*.gif **/*.png \*.png
STEP 2:
git commit **/*.jpg \*.jpg **/*.gif \*.gif **/*.png \*.png -m "Image commit"
STEP 3:
git push --all

GIT add PDF

STEP 1:
git add **/*.pdf \*.pdf
STEP 2:
git commit **/*.pdf \*.pdf -m "Image commit"
STEP 3:
git push --all

GIT Add Single File

STEP 1:
git add <file_name>
STEP 2:
git commit <file_name> -m "comment"
STEP 3:
git push

GIT Merge

STEP 1:
git fetch --all
//git fetch downloads the latest from remote without trying to merge or rebase anything.
STEP 2:
git reset --hard origin/master
//Then the git reset resets the master branch to what you just fetched.

Clean Aborting

git reset --hard HEAD
git clean -f -d
git pull

 

Git Export tar.gz  Archive

// Show All Revision Number: $ git log --all --graph --oneline
//Export All Files Between 2 Date
//git log --since --before
tar czf changed-files.tar.gz $(git log --after={2013-06-17} --name-only --pretty=format: | sort | uniq)
//Export All Files Between 2 Commit
tar czf changed-files.tar.gz $(git log ^46a2752 6d365ed --name-only --pretty=format: | sort | uniq)

GIT  Reset Previous Commit

STEP 1
git log
/* 
commit f81c44262661d977250086ebd59e4427a9085c47
Author: iman <iman@bitmascot.com>
Date:   Fri Feb 7 14:46:14 2014 +0600 
*/
STEP 2
git checkout master
STEP 3
git reset --hard f81c44262661d977250086ebd59e4427a9085c47
STEP 4
git stash
git push -f origin master:master
git stash pop
// If you want to throw away all your changes on master and want to have it exactly the same as origin/master
git checkout master
git reset --hard origin/master

GIT  Reset Previous Commit

STEP 1:
git reflog show
/*
Result:
edbfd0d HEAD@{0}: commit: Import code from development environment.
da39602 HEAD@{1}: checkout: moving from master to development
*/
STEP 2:
git reset --hard da39602