0% found this document useful (0 votes)
47 views

Creating New Git Repository

Git is a version control system that allows developers to work collaboratively by creating branches. It encourages branching by allowing developers to create topic branches off the master branch to work independently. Branches can be merged back into master after work is completed. If conflicts arise during merging, developers must resolve them before completing the merge. Git provides commands to view differences between commits, branches, and the local and remote repositories to help with collaboration.

Uploaded by

Navneet Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Creating New Git Repository

Git is a version control system that allows developers to work collaboratively by creating branches. It encourages branching by allowing developers to create topic branches off the master branch to work independently. Branches can be merged back into master after work is completed. If conflicts arise during merging, developers must resolve them before completing the merge. Git provides commands to view differences between commits, branches, and the local and remote repositories to help with collaboration.

Uploaded by

Navneet Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

GIT

Creating new git repository: cd wordpress_git git init cd .. cp -ra wordpress/* wordpress_git cd wordpress_git git add . git commit -m "first commit"

Committing code in GIT repo git add filename git commit -m "msg" filename Ignoring any file in any directory of whole git repository: make entries in file .gitignore ! means not files without / are checked aginst basename / means current directory every repo have .git/info/exclude .gitignore and exclude work together. .git/info/exclude will not be cloned.

Configuration of git repositories: git-config name value git-config name git-config -l #set name and value #get current value #get all values

GIT encourages branching: Create a branch: git-checkout -b topic-name master work on this branch Commit and Merge:

git-checkout master git-merge topic-name Delete branch git-branch -d topic-name Merging branches and getting conflict: Two different people work on two different branches: A works on branch A: git checkout master git checkout -b branchA master

B wants to work on his branch: git checkout master git checkout -b branchB master Now the situation is as follows: master / \ branchA branchB

Now we can do two things: Merge and Rebase: Merge: master / \ branchA branchB \ / master

STEPS: A has completed his work he will merge his branch with master and then delete his branch

git checkout master git merge branchA git branch -d branchA B has now completed his work and he want to merge and then delete his branch git checkout master git merge branchB CONFLICT EXIST NOW. B will resolve the conflict and then merge the branchB with master code. Then git branch -d branchB

Rebase: master X \ barnchA -- branchB \ master we relocate the parent of branchA with branchB and pretend that we checkout the branch from branchB. Checking Logs: LOG git-log git-log -p # print difference b/w revisions git-log --stat # statistics git-log file1 file2 file3 # log for specified files Checking differences

git-diff git-diff HEAD git-diff --cached git-diff OTHERBRANCH

# difference b/w commited and current code # difference b/w # # difference b/w current and OTHERBRANCH

git-diff BRANCH1 BRANCH2

# difference b/w BRANCH1 and BRANCH2

Working with others: git-clone #to create the copy of remote directory

git clone ssh://newstage.investmentpal.com/home/ivpl/repo/.git git-pull git-push git-fetch #to get changes from remote directory #to send changes to remote directory #updating our repo with remote repo.

You might also like