GIT Hands-on : 2
These steps assume that you have already installed Git Bash on your computer and have created a GitHub account.
If you need help with these prerequisites, you can refer to the kshitijaa.hashnode.dev/git-hands-on-1
Set your user name and email address, which will be associated with your commits.
\Here you have to put Username and password of your GitHub account\
git config --global user.name "username"
git config --global user.email "username@gmail.com"
Verify your configuration info
git config --list
How to connect local to remote? [Git to GitHub Conenction]
Create Repository in GitHub
1. Click on the new repository option
2. Now give a name of your repository as per your choice and a description.
3. Choose the Visibility to public /private as per your requirement.
4. Before hitting the create button you can include a README file
5. Click on Create button and a new repository will be created.'
Access Repository from Local Machine
1. To initialize a local repo in the machine create a folder and go to that folder (say /GIT_REPO). Open Git bash terminal and write the command git init. Here .git hidden folder will be created.
git init #make GIT_REPO folder as git repository
2. Create/Add the files to your new local repository. This stages them for the first commit.
touch file1 #create a file
git add file1 && git commit -m "added new file" #perform git add & commit
3. Add the URL for the remote repository where your local repository will be pushed.
git remote add origin <URL_OF_GitHub_REPO.git>
4. Enter your username and Personal access token to push your codes to the central repo (GitHub)
git pull #always pull before push
git push -u origin master #here you can use master or main