GIT & GITHUB MASTERCLASS
1. What is the difference between pushing and pulling?
Ans:- Push - pushing sends the recent commit history from your local repository up to GitHub. ... Pull - a pull grabs any changes from the GitHub repository and merges them into your local repository.
2.How to initialize a new git repository [Describe all the steps ]..?
Ans:- A NEW REPO FROM SCRATCH
1) Create a directory to contain the project.
2) Go into the new directory.
3) Type git init.
4) Write some code.
5) Type git add to add the files
6) Type git commit.
The first file to create (and add and commit) is probably a ReadMe file, either as plain text or with Markdown, describing the project.
CONNECT IT TO GITHUB
Ans:- Go to github.
Log in to your account.
Click the new repository button in the top-right. You’ll have an option there to initialize the repository with a README file, but I don’t.
Click the “Create repository” button.
3. What is the use of git clone and how to use it?
Ans:- git clone is primarily used to point to an existing repo and make a clone or copy of that repo at in a new directory, at another location. The original repository can be located on the local file system or on remote machine accessible supported protocols. The git clone command copies an existing Git repository.
4. How to ignore some files/folders from pushing?
Ans:-
1) Go to .gitignore file and add the entry for the files you want to ignore.
2) Run git rm -r --cached .
Now run git add .
5. What do you mean by Branch?
A branch is essentially is a unique set of code changes with a unique name. Each repository can have one or more branches. ... This is the official working version of your project, and the one you see when you visit the project repository at github.com/yourname/projectname. Do not mess with the master.
● Which branch should be used to keep deployment-ready code?
The developers in the team constantly commit their work into a single, central branch—which is always in a deployment-ready state. In other words, the main branch for the project should only contain tested and quality work, and should never be broken.
● Create a new branch called development from the main branch.
1) git branch <branch-name> Copy.
2) git checkout <branch-name> Copy.
3) git checkout -b <branch-name> Copy.
4) git push -u <remote> <branch-name> Copy.
● Checkout one more branch deployment from the previous branch.
select the branch that you want to merge into the current branch and choose Merge into Current from the submenu.
If you need to specify merge options, from the main menu choose VCS Git | Merge Changes to open the Merge dialog
● Push different data into both branches.
apply already existing commit to another branch using cherry pick command, and then push both branches using git push origin branch A & branch B.
● Merge data from both branches to the main branch.
Merging your branch into master is the most common way to do this. Git creates a new commit (M) that is referred to as a merge commit that results from combining the changes from your feature branch and master from the point where the two branches diverged.
Regional Operations Lead, Smart Joules Pvt. Ltd.
3yThank you so much for the detailed info. Nice to know such in-depth technical concepts.