An Article on GIT and GITHUB
1. What is the difference between pushing and pulling..?
Pulling - Pulling is the opposite of pushing. It allows you to make changes in your local repository from any remote location. it's more useful in group work or a big project where more than one person can submit changes to a single repository
Pushing - Pushing sends your changes up to GitHub, so they can be shared with your project teammates. It also serves as a hedge against data loss.
suppose if you are working on the repository alone then it's easy to push. but If there are other members who want to access the same repository then you need to pull before you push up to GitHub
2. How to initialize a new git repository [ Describe all the steps ] ..?
There are few steps to initialize a new git repository -
- We need to create a directory on GitHub to contain the project.
2. Go to the newly-created directory.
3. Open git bash and type - git init (to initialize the new repository).
4. Write something codes and type - git add ( to add the files into our repository ).
5. Then type - git commit (to save your file in the repository ).
3. What is the use of git clone and how to use it?
git clone is mainly used to selecting an existing repository and make a copy of that repository in a new directory, at another location. The original repository can be located on the local machine.
?Steps to make git clone -
1. Open git bash.
2. Go to the repository which we want to make a clone.
3. Type - git clone <repository URL> ( to make a copy of the existing repository ).
4. After making any changes in the cloned repository you need to commit every time because it will not change in the original repository.
5. When you complete your work you can push it into GitHub.
4. How to ignore some files/folders from pushing?
To ignore files/folders we need to create a .gitignore file in your Git repository to prevent Git from staging unwanted files. Share .gitignore in the default branch in your repository. You and your teammates can update the file to change which types of files to ignore.
5. What do you mean by Branch?
A branch represents an independent line of development. The git branch command lets say create, list, rename, and delete branches. It doesn't let us switch between branches or put a forked history back together again.
- Which branch should be used to keep deployment-ready code?
In GitHub, the main branch contains our production-ready code. The other branches contain work on new features and bug fixes.
- Create a new branch called development from the main branch.
$ git branch development
- Check out one more branch deployment from the previous branch.
$ git checkout development
$ git checkout -b development
- Push different data into both branches.
$ git push -u <remote> development
- Merge data from both branches to the main branch.
$ git merge new-feature
Software Engineer II at JPMorgan Chase & Co.
3 年Good work ??
ERP Business Analyst at Schneider Electric, Bangalore, India.
3 年Well done??