GIT AND GITHUB
Ashish Patil
Software Developer @ Ceyone | Ex-Intern @ IIT Bombay | Full Stack | Python Django | MERN Stack | AWS | CSE @ SPPU
Git and GitHub is not same but the technology at they are working is same.
Git : Git is Version Control System(VCS) which we use to control and track versions of our projects. It also provides services for managing folders in our system called as Repositories. It is a very powerful tool and used for tracking changes in computer files and coordinating work on those files among multiple people.
GitHub : GitHub is cloud based service(source code hosting service) that provides hosting for git.
1. What is the difference between pushing and pulling..?
Pushing: It is the process used to upload or transfer content/commits from our local system to a remote server(local repository to remote repository). Pushing exports commits to remote branches. The command used for pushing is <git push>.
Pulling: It is the process used to fetch data from remote server to local system(remote repository to local repository). Pulling imports commits to local branches. The command used for pulling is <git pull>.
2. How to initialize a new git repository[Describe all the steps]..?
Step 1: Create a directory/folder to contain the project.
Step 2: Go into the new directory/folder.
Step 3: Type <git init> to initialize git repository.
Step 4: Write some code, add files.
Step 5: Type <git add> to add the files in staging area.
Step 6: Type <git commit> to commit files.
3. What is the use of git clone and how to use it?
Cloning: Cloning is used to fetch entire remote repository into your local system without initializing. It is a process of creating an identical copy of a Git Remote Repository to the local machine. When we clone a repository, all the files are downloaded to the local machine but the remote git repository remains unchanged. Making changes and committing them on your local repository will not affect the remote repository that you cloned in any way. These changes made on the local machine can be synced with the remote repository anytime the user wants.
How to use git clone?
Step 1: On GitHub, navigate to the main page of the repository.
Step 2: Above the list of files, click Code.
Step 3: Copy web URL.
Step 4: Open Git Bash.
Step 5: Change the current working directory to the location where you want the cloned directory.
Step 6: Type git clone, and then paste the URL you copied earlier.
Step 7: Press Enter to create your local clone.
4. How to ignore some files/folders from pushing?
Ignored files are tracked in a special file named .gitignore that is checked in at the root of your repository. There is no explicit git ignore command: instead the .gitignore file must be edited and committed by hand when you have new files that you wish to ignore. .gitignore files contain patterns that are matched against file names in your repository to determine whether or not they should be ignored.
5. What do you mean by Branch?
A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master. As you start making commits, you’re given a master branch that points to the last commit you made. Every time you commit, the master branch pointer moves forward automatically.
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 master branch and created development branch)
Checkout 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 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 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 )
git merge deployment (Merge deployment branch with master branch )
THANK YOU