git and GitHub
1. What is the difference between pushing and pulling..?
?Pulling is done to review the changes that user has done in the local server and then merge the changes into Github (master) repository.
Pushing is done when user has to commit any changes to remote (Github) that made into the local repository
2. How to initialise a new git repository[ Describe all the steps ]..?
Steps:
Step1: Create new respository on git by using command mkdir.
-mkdir regex-1
Step2: Type git init to initialise an empty git repository within the directory.
Step3 : Create a file using echo command
- echo "# regex-1-uchita" >> uchitagupta.md
Step4 : Type git add to add the file on remote
- git add uchitagupta.md
Step5 : Type git commit to push your file on remote
- git commit -m "my first file"
3. What is the use of git clone and how to use it?
Git clone is used for making a copy for existing repository at in a new directory or at another location. The original repository can be located on the local filesystem or on remote machine accessible supported protocols. The git clone command copies an existing Git repository.
git clone <repo> <directory>
: Clone the repository located at <repo> into the folder called ~<directory>! on the local machine.
Step1: Go to page of repository that user wants to clone.
Step2: Press Clone or download button
Step3: Copy the URL appears after clicking clone button.
Step4: Now, go to the git bash and type the command
-git clone <url>
Step5: Confirm the cloning after running the above command using ls command.
4. How to ignore some files/folders from pushing?
While working on project, you want some files not to be pushed on git repositories or files will not get public. you can use .gitignore to exclude the assets directory totally from version control (on both local and remote repos)
5. What do you mean by Branch?
A branch represents an independent line of development. 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.
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.
Create a new branch called development from the main branch.
git branch development origin/main
OR
git checkout -b development origin/main
Checkout one more branch deployment from the previous branch.
git checkout -b deployment origin/development
Push different data into both branches.
git checkout development
git add <file>
git commit -m "commit on branch development"
git checkout deployment
git add <file>
git commit -m "commit on branch deployment"
Merge data from both branches to the main branch.
git checkout main
git merge development deployment
git branch -d deployment
git branch -d development