— — — — — — — -Introduction of git — — — — —
First of all git and github are two different thing github is a service which provide repository or folder for your code and git is a software configuration or source code management tool or to manage the different versions of your code
source code management tools are of two types →
1.Centrilised version control System (CVCS)
2.Distributed version control System (DVCS)
problems with CVCS :-
1.There is no copy of code available
2.if repository being down than all collapsed
3. as there is no copy of code available and you need an internet connection all the time you try to connect to repository
4.since everything is centralised if control server gets failed you will lose your data
Git is used to overcome all these problems .Git is a dvcs tool which means the code written by you is in distributed form or there is a local repo is present in your device where you commit your code before push it on github which means if your github or central repository being down your code is available to work now your code is distributed or more copy of your code is available.
Architecture of Git -:
Three parts of git folder →
1.Working directory — — it is a part where all your code is present
2.Staging area — — it is that part where you can add file or code from working directory that is need to be commited or add to local repository
3. Local repository — — here you can add your final code which you can upload on central server or github
Before working — —
1.first of all we need to install git using “ apt install git” command in linux you can also use it in windows
2.Next you will make a folder where you are working with git
3. now run git init command to initilize a folder as git folder
4. the folder is now divided in 3 parts run ls -a for check
Commands to push your code on github from local System →
- make a folder →mkdir git
- git init →to initialize git personal directory
- git -version
- git config — global user.name “your name”
- git config — global user.email “your email”
- git status →now you are present in working directory make a file or add it to staging area using the command below →
- git add .
- git commit -m “ your message” (to add your code in local repo)
- git log →give info who is commit the code
- git show <commit id> →information about the commit
- git remote add origin <git repo url> →where the code is uploaded
- git push -u origin master →then you need to enter your github id and password to push the code on particular repo
- git pull -u origin master →first you need to give the url of that repo by above command