Git is a distributed version control system that helps developers track changes to their code and collaborate with others effectively. It allows you to manage different versions of your code, work on new features without interfering with the main codebase, and merge changes from multiple contributors seamlessly.
bashCopy code
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git clone <repository-url>
Replace <repository-url>
with the URL of the remote repository you want to clone. You can find the URL on the repository’s homepage on the platform it’s hosted (e.g., GitHub).Creating a Repository:
git init
Adding and Committing Changes:
git add <file_name
git add .
git commit -m "Commit message describing changes"
Pushing and pulling changes
git push -u origin <branch-name>
Replace <branch-name>
with the name of the branch you want to push. For example, to push changes from the local branch feature
to the remote repository, you can use:
git push -u origin feature
git pull
git pull origin <branch-name>
Replace <branch-name>
with the name of the branch you want to pull changes from. For example, to pull changes from the remote branch main
into your current local branch, you can use:
git pull origin main
Checking the Repository Status:
git status
Viewing History:
git log
git show <commit_hash>
Branching:
git branch <branch_name>
git checkout <branch_name>
Merging:
git checkout <target_branch>
git merge <source_branch>
Remote Repositories:
git remote add origin <remote_repository_url>
To view the URL of the remote repository named “origin” in your Git repository, you can use the following command:
git remote show origin
This command will display information about the remote repository named “origin,” including its URL, fetch and push URLs, the branches that are tracked, and more.
If you have multiple remote repositories and want to see the names and URLs of all of them, you can use:
git remote -v
This command will show a list of all remote repositories and their corresponding URLs, both for fetching and pushing. It’s a handy way to see all the remote repositories connected to your local repository and verify their configurations.
Handling Conflicts:
Address: Alsa Sheridan, 12-B, Sridharan St, Ayyavoo Colony, Aminjikarai, Chennai, Tamil Nadu 600029
Address: S-23, SIPCOT Industrial park, Pillaipakkam, Tamil Nadu 602105
Address: SP-153 2nd Floor, 9th Ln, near Coffee Day, Ambattur Industrial Estate, Chennai, Tamil Nadu 600058
12-B, Alsa Sheridan,
Sreedharan Street,
Aminjikarai,
Chennai-29, Tamilnadu,
India