Git:
Lets discuss first what is git, Git is one of the most useful tools that any developer has up their sleeves. No matter what kind of development you are doing, understanding how to use Git will be a valuable asset that can save your butt.
Git is a version control system. It tracks any changes made to files in a directory and keeps a record of previous versions of these files.
Installing Git:
Download git for windows from the official site here link. Keep going through with the installation. To check if you have correctly installed git, use this command in your git terminal
git --version
Creating A GitHub Repository:
Login to your GitHub account(If not there, sign up for a Github account).
Click on "New" repository.
Enter a repository name.
Click on create repository.
Basic Git Commands:
1. git init
For initializing a git repository in the current directory (specified in your terminal).
git init
2. git config
When you start using Git, you'll need to put in a username and an email id (given you didn't change the settings of the setup.
git config --global user.name "Your Username"
git config --global user.email youremail
3.git add .
This command is a shortcut for adding all the files inside your folder to the staging area rather than writing each file name one by one.
git add .
(or)
git add filename
4. git status
git status show modified files in working directory, staged for your next commit
git status
5.git commit :
This command commits to staging with a message. Commits are saved changes and explain to others what you have done in the project.
git commit -m "write your commit message here, eg. made changes to the header"
6.git branch:
By default, the branch in which we make all our changes is called the 'main' branch. If we want to mess with our code in a separate environment without breaking our code in the main branch, we can create new branches and do what we want there.
git branch -M main
7. git log:
This is used for showing the commit history of the repository. Git log displays
git log
8.git remote
Now it is time to use the repository that we created on GitHub.
remote add origin We need to connect our local repository to the one on GitHub. We can do so by using this command:
git remote add origin https://github.com/yourusername/nameoftherepo.git
9.git pull
When you want to see the changes made by your teammate, you can pull back the file into your local repo with this command.
git pull
git push
To push all the changes into your remote repo, use this command.
git push -u origin main
Thankyou for reading the blog if you found it helpful do give it a thumbs up and please add your valuable inputs as well:-)
Rohini