Skip to main content

GIT INTRODUCTION AND SOME COMMANDS EVERY PROGRAMMER SHOULD KNOW


What is git?
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.

In mac you already got Bash but in windows you get Bash when you install git Bash. So in mac you will use terminal for your git, but in windows you get separate git terminal. git Bash is unix based terminal..

Firstly, you have to config the user name and email address..You have to simply open the git terminal and write the command.

                    git config --global user.name set the username               
                     git config --global user.email set the email          

To check the user name or email simply type git user.name or git user.email..

The git init command creates a new Git repository. It can be used to convert an existing, unversioned project to a Git repository or initialize a new, empty repository. This is usually the first command you'll run in a new project.

To add a file in a repository we have a command:

                     git add filename                            

But if we want to add many files than we can use the command:

                     git add -A                                      

 

This is a simple image to understand the git repository file system..

We always do a one initial commit to track the files.To commit we have a simple command

                  git commit               

and than a Vimeditor is open 
for write press insert and  after making changes to a file, press [Esc] to shift to the command mode and press :w and hit [Enter] to save a file.

for avoid Vimeditor we have an alternate solution:

                 git commit -m "write first commit"      

Git checkout:-->To match the last commit 

                git checkout filename ---for a single file     
                git checkout -f  -----for many files               

Git log:-->Show the commit message


                git log                         

and to filter the git log 

               git log -p                     

To compare the working directory to the stagging area..

               git diff                         

and to compare the last stagging area 

               git diff --stagged        

There is also a command which directly commit the file without the stagging area..

                git commit -a -m "skipped stagging area"                


If we want to remove the file from the stagging area but the file present in the hard disk than there is a command:
git rm --cached filename

And if we want to remove the file from the stagging as well as from the hard-disk.
git rm filename


To view the shorthand status there is a simple command:

                                     git status -s                                    
1st box denote the stagging area
2nd box denote the working directory

Git Branch:-->By default the master is the main branch and if we want a separate copy  so that there is no effect in the original code if we edit or fix some bug in the trial purpose we create a separate branch...This is the "killer feature" in the git..

To add a branch: 

              git branch branch-name               

 To switch the branch: 

              git checkout branch-name             

To merge the branch

              git merge branch-name                

If we want to create a new branch and also to switch in that branch there is an alternate command:
                            
                                            git checkout -b branch-name 





























Comments

Popular posts from this blog

How to upload a csv file in django?

csv file:--> It stands for comma separated value files.It is in the form of the tabular format and we can open it in Microsoft Excel. Now see how we can upload it in the django..first we create a project in django.to create a project the commands are as follows:           django-admin startproject csv      $ cd csv      $ python manage.py startapp csvfile Once we have created an app we have to add this app in the INSTALLED_APPS  in settings.py. In the models.py we have to created two class one is Bank and other is Branch. from  django.db  import  models class   Bank ( models . Model ):     name = models.CharField( max_length = 50 )      class   Meta :         ordering = ( 'name' ,)      def   __str__ ( self ):          return   " {} ...

Django (web framework) Programming and Development

Introduction: Django is a Python-based free and open-source web system, which takes after the model-view-template (MVT) building design. It is kept up by the Django Computer program Establishment (DSF), an autonomous organization built up as a non-profit. Django's essential objective is to ease the creation of complex, database-driven websites. The system emphasizes reusability and "pluggability" of components, less code, coupling, quick advancement, and the guideline of do not rehash yourself. Python is utilized all through, indeed for settings records and information models. Django too gives an discretionary administrative create, examined, upgrade and erase interface that's produced powerfully through contemplation and designed through admin models. A few well-known destinations that utilize Django incorporate the Open Broadcasting Benefit, Instagram, Mozilla, The Washington Times, Disqus, Bitbucket, and Nextdoor. It was utilized on Pinterest, but afterward the loc...

How to create user-register form,login,logout and also make a profile of each user register in Django?

Django provides a quite easy way to create a User-Registration as all are already presents in the Django we just know how to use this..Here, we will see how to easily implement this and create a profile of all users which are register.This article will be an interesting and important so please read out seriously. firstly we have to start a project and than start an app:     django-admin startproject user-authentication     $ cd user-authentication     $ python manage.py startapp users Once we have created an app we have to add this app in the INSTALLED_APPS  in settings.py. Than we have to add the path of the accounts app: "main project urls.py" from  django.contrib  import  admin from  django.urls  import  path,include from  django.conf  import  settings from  django.conf.urls.static  import  static from  users  import  views  as  user_views from  ...