Lets clear out the differences and an overview. Git vs GitHub
Git:
Git is a distributed version control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows.
GitHub:
GitHub is a web-based Git repository hosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features.
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?
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?
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).
This default configuration is achieved by creating references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables.
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 usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are:
- dependency caches, such as the contents of /node_modules or /packages
- compiled code, such as .o, .pyc, and .class files
- build output directories, such as /bin, /out, or /target
- files generated at runtime, such as .log, .lock, or .tmp
- hidden system files, such as .DS_Store or Thumbs.db
- personal IDE config files, such as .idea/workspace.xml
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 )