Article on Git and Github

Difference between Git and Github:-

Git is a version control system used for keeping track of changes of any file uploaded on Github. This is mainly used to keep track of changes for a file. A group of people can work on the same code without rendering the main code and add or remove changes according to their requirements.

Whereas, Github is a cloud-based service that provides hosting for git services. Additionally, it adds many of its own features.


Ques. 1 What is the difference between pushing and pulling?

Pull commands help to fetch code or files from a remote repository to one local repository. It also pulls any request from the Git repository and merges them to a local repository.

On the other hand, the push command is used when one has to upload or send the commits to a remote repository from a local repository. It sends content or codes to another repository.


Ques 2. How to initialise a new git repository[ Describe all the steps ]?

-> Create a directory to store the project.

-> Go into the new directory.

-> Enter the command "git init"

-> Write some code or content you want to upload in the git repository.

-> Enter "git add" to add all the required files

-> FInally, enter "git commit" to commit all the files.


Ques 3. What is the use of a git clone and how to use it?

Clones a repository into a newly-created directory, creates remote-tracking branches for each branch in the cloned repository (visible using git branch --remotes), and creates and checks out an initial branch that is forked from the cloned repository’s currently active branch.

After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will, in addition, merge the remote master branch into the current master branch, if any (this is untrue when "--single-branch" is given; see below).

Following are the steps on how to use the git clone:

-> Open the main page of the repository on Git Clone.

-> Click "code", above the list of files.

-> Copy web URL.

-> Now, open Git Bash.

-> Change the current working directory to the location where you want the cloned directory.

-> Type git clone, and then paste the URL you copied earlier.

-> Press "enter" to create your git clone.


Ques 4. How to ignore some files/folders from pushing?

To ignore some files, you can create a .gitignore file in your repository's root directory to tell Git which files and directories to ignore when you make a commit. To share the ignore rules with other users who clone the repository, commit the .gitignore file into your repository. There is no explicit command to make a .gitignore file, instead, users have to make the file themselves and edit it accordingly. Steps to create a gitignore file-

-> Open Git Bash.

-> Navigate to the location of your Git repository.

-> Create a .gitignore file for your repository.

The files mentioned in the gitignore file should match the exact same name as the original file, else it will be ignored and the purpose of the .gitignore file will not be accomplished.


Ques 5, What do you mean by Branch?

A branch in Git is a way to keep developing and coding a new feature or modification to the software and still not affecting the main part of the project. We can also say that branches create another line of development in the project. The concept is similar to the branches of the tree. The primary or default branch in Git is the master branch (similar to the trunk of the tree). As soon as the repository creates, so does the main branch (or the default branch). Once the branch creates, the whole main code from the main branch gets copied to the newly created branch. Whereas, in Git, the code is separated only from the point of creation of the branch. Once the creation of the new branch happens, we can switch to this branch and start development.

  • Which branch should be used to keep deployment-ready code?

Production Branch(Develop)

  • Create a new branch called development from the main branch.

git checkout -b development (Now, we are in the master branch and created development branch)

  • Check out one more branch deployment from the previous branch.

git checkout development (checkout in development branch from master branch)

git checkout -b deployment (Now, we are in the development branch and created deployment branch)

  • Push different data into both branches.

git push (Push data in development branch)

git checkout deployment (checkout in deployment branch from a development branch)

git push (Push data in deployment branch)

  • Merge data from both branches to the main branch.

git checkout master (checkout in master branch from deployment branch)

git merge development (Merge development branch with master branch )

要查看或添加评论,请登录

Priyanshi Agarwal的更多文章

  • EXLORATORY DATA ANALYSIS

    EXLORATORY DATA ANALYSIS

    Data Set used: supermarket sales What is EDA? EDA is an approach of analyzing the dataset to summarize the main…

社区洞察

其他会员也浏览了