- Git is officially defined as a distributed version control system (VCS).
- It's a system that tracks changes to our project files over time. It enables us to record project changes and go back to a specific version of the tracked files, at any given point in time.
- Download git from this url
- Check if git is downloaded by using
git --version
- git config --global user.name "Your Name"
- git config --global user.email "[email protected]"
Note :-
- Git is seperate from github and gitlab
- Git is the program that supports github and gitlab
- You can use git without either of those
To create a new repository and start tracking your project with Git, use your terminal software and navigate to the main folder of your project, then type the following command:
git initCheck the changes that are made:-
git statusAdd files that you want to change:-
git add <filename>
git add .Commi the changes:-
git commit -m "<message>"
git commit Add the repo URL:
git remote add origin <url>
git push --set-upstream origin masterCheck the commit history using:-
git logGo the to necessary commit by using:-
git checkout <commit-hash> To go back to the latest commit use:-
git checkout masterSee all branches by using
git branchCreate a new branch
git branch <branch_name>Go to the new branch
git checkout <branch_name>Commit changes in branch
git push origin <branch_name>Now to update the merge the changes in the new branch to master go to master branch using
git checkout masterThen merge the changes using
git merge <branch_name>Then commit the changes
If u want to create a local copy of the repo then use the clone command
git clone <url>