Git-instructions-and-set-up
INSTALLING GIT INTO YOUR PC
1. Go to the official website of Git and download the version of Git that suits for your computer. Link - https://git-scm.com/,
2. Follow the recommended settings for the installation. Make sure a desktop shortcut and a stat menu app is installed.,
3. Press 'Finish' when it is installed.
Creating A Git Repository
1. Go to you profile on the upper right corner of the screen.
2. Select 'Your Repositories'.
3. Click on 'New'. And give your project a name.
4. Then click on 'Create Repository'.
Cloning the repository into your PC.
1. Open a directory where you want to work on your project on file explorer on windows.
2. Right click and select 'Git Bash'. A terminal will open.
3. Open your GitHub repository on that you want to clone on the browser. Click on 'Code'. And copy the first web URL.
4. Open the Git Bash and type 'git clone' and then paste the URL. Press Enter.
5. A new folder with the repository name will appear in your preferred directory along with the files in it.
6. Finally close the Git Bash. Go to the folder that has been created. Right Click and open Git Bash. This will change the directory to the space where you will be adding your files.
Checking Git status (Changes in the project)
1. In the Git Bash just type 'git status'. Press Enter.
This will show every change or any required change in the project.
Adding a new file to the project directory using Git Bash
1. Copy the file you want to add, directly to the directory you are working on.
2. On the Git Bash type 'git add' and then enter the file name along with the extension.
Or if you want to add all files together just type 'git add .'. This will add all the new file automatically. We need to do this adding file before we push it and send it the main GitHub repository.
Commit new files to the GitHub repository using Git Bash
1. After we have added a new file, we need to commit the changes that is add a comment on what has been changed.
2. To make a commit in Git Bash type 'git commit -m "add your comment here" ' you can add your comment. Press enter.
Pushing the new files into the GitHub repository
1. Before pushing the new files into the repository we need to add them and make the necessary commits.
2. On Git Bash type 'git push' or 'git push origin 'select branch'', the repository can have many branches. Select the branch accordingly.
Changing a file data
If any changes are made in a file the file needs to be added and Committed before it is pushed into the repository.
Follow the above commands to do what is needed.
Log In to your GitHub ID before Pushing
Sometimes if the browsers logged in email is different from the GitHub email then we have to log in using the Git Bash.
Also, even if we reopen the Git Bash we have to select the email of the GitHub where we want to make the changes including the adding of files,
To enter the necessary email type 'git config --global user.email "your email"'
Git Pull command
This command is used to pull over the changes in the repository directly to your project in the PC directory.
To pull up the changes just type "git pull". And your files will be updated
Creating a New branch
Branches are copies of the repository. A repository mainly has only one branch that is 'master', but we can make new branches if we want to work on a copy of the repository and Make changes accordingly to the main code.
To create a new branch we just need to type 'git branch ' and the branch name. The press enter.
Switching to a new branch
To switch to a new branch just type 'git checkout' and the branch name. The press enter.