Skip to content

Git Research

Yasin ATLI edited this page Apr 19, 2024 · 1 revision

What is Git ?

Git is a popular version control system. It was created by Linus Torvalds in 2005, and has been maintained by Junio Hamano since then.

It is used for:

  • Tracking code changes
  • Tracking who made changes
  • Coding collaboration

What does git do ?

  • Manage projects with Repositories
  • Clone a project to work on a local copy
  • Control and track changes with Staging and Committing
  • Branch and Merge to allow for work on different parts and versions of a project
  • Pull the latest version of the project to a local copy
  • Push local updates to the main project

Working with Git

  • Initialize Git on a folder, making it a Repository
  • Git now creates a hidden folder to keep track of changes in that folder
  • When a file is changed, added or deleted, it is considered modified
  • You select the modified files you want to Stage
  • The Staged files are Committed, which prompts Git to store a permanent snapshot of the files
  • Git allows you to see the full history of every commit.
  • You can revert back to any previous commit.
  • Git does not store a separate copy of every file in every commit, but keeps track of changes made in each commit!

Git branches

Branch Creation

While working in a Git repository, you may want to work on new features or changes without disturbing the current state. In this case, you create a separate branch from the current state. This allows you to add new features or make changes without altering the current working directory.

Command Example:

git branch new-feature

Parallel Development

If multiple developers are working on a project or different features need to be worked on simultaneously, you can create a separate branch for each developer or feature. This supports parallel development processes and prevents conflicts.

Command Example:

git branch new-feature

Version Control

Each branch represents a specific state of the project. These states could be when a specific feature is added or a particular bug is fixed. Branch names typically describe this state explicitly, so branches can represent past versions of the project.

Command Example:

git branch bug-fix

Branch Merging

Merging changes made in different branches is a powerful feature of Git. When a feature is developed or a bug is fixed, the changes from the respective branch are merged into the main branch (usually master). This consolidates different parts of the project to keep it up to date.

Command Example:

git merge new-feature

Deleting or Merging Branches

If a branch is no longer needed or has served its purpose, it can be deleted. Additionally, after a branch's changes have been merged into another branch, the branch may become unnecessary and can be safely deleted.

Command Example (Deleting a Branch):

git branch -d new-feature

Git branches are an essential tool for managing and organizing a project. When used correctly, they support parallel development processes, facilitate tracking and management of changes, and help keep the project organized.

Git Remote Repositories

Remote repositories in Git are copies of your project hosted on other servers. They allow multiple developers to collaborate on a project by sharing their changes with each other. Remote repositories are essential for distributed version control and facilitate collaboration among team members.

Adding a Remote Repository

To add a remote repository, you use the git remote add command followed by a name for the remote and the URL of the remote repository. This associates a name with the URL, allowing you to refer to the remote repository by its name in future commands.

Command Example:

git remote add origin <repository_URL>

Listing Remote Repositories

You can list the remote repositories associated with your local repository using the git remote command. This command lists the names of all remote repositories.

Command Example:

git remote 

Fetching Changes from Remote Repositories

To retrieve changes from a remote repository, you use the git fetch command. This command downloads changes from the remote repository to your local repository, allowing you to see what others have been working on.

Command Example:

git fetch origin

Pulling Changes from Remote Repositories

To incorporate changes from a remote repository into your current branch, you use the git pull command. This command fetches changes from the remote repository and merges them into your current branch.

Command Example:

git pull origin master

Pushing Changes to Remote Repositories

To upload your local changes to a remote repository, you use the git push command. This command sends your committed changes to the remote repository, making them accessible to other team members.

Command Example:

git push origin master

Removing Remote Repositories

If you no longer need to collaborate with a particular remote repository, you can remove it using the git remote remove command followed by the name of the remote repository.

Command Example:

git remote remove origin

Remote repositories play a crucial role in collaborative software development, allowing teams to work together efficiently and effectively.

💻 Project

🎯 Meetings

🎯 Mobile Meetings

💻 Lab Reports
📝 Milestone Reports
👨🏽‍🤝‍👨🏾 User Group Scenarios
👨🏻‍💼👩🏻‍💼 User Scenarios
👤 Personal Pages
📝 Templates

Archive

Animal Trove Project ### 💻 Project

🔍 Research

🎯 Meetings
👤 Personal Pages
📝 Templates
Clone this wiki locally