Research on Git - bounswe/2021SpringGroup9 GitHub Wiki

What is Git?

Git is a version control system for tracking changes in files. It was created by Linus Torvalds back in 2005. Git tracks what is changed, who changed it, when it was changed. And also you can revert back to any version of the file that has been committed. This gives developers a huge benefit such as in case of any bugs or missdevelopments.

Git allows you to work with multiple developers without having to be on the same network. This is due to the distributed (decentralized) concept of Git. Also another cool feature of git is that any contributor can start up his/her own branch and not effect the other people's work. This is really helpful when working in a group project.

Some Useful Git Commands

There are basically two labels: HEAD and BRANCH

git init: initialize an empty git repository in the directory

git clone <url>: clone an existing repository into the directory

git add <filename>: writes the file into the repository

git commit: creates a commit object with an ID and labels it (head & branch)

git branch <branchname>: create a new branch (local until push)

git push -u origin <branchname>: push branch to the remote repository

git checkout <branchname>: switch to the new branch (move HEAD label to the new branch where commits to the repository will go)

git checkout -b <branchname>: create and switch to the new branch

git merge <branchname>: merge with the current parent branch

git branch --list: list all branches

git branch -d <branchname>: delete the branch


This is how branching and merging work:




git reset --hard <commitID>: move the HEAD label back to the commit ID

git reset --hard HEAD^: move the HEAD label back by one commit

git status: information about the current branch (files that are created, commits, push, pull etc.)

git push origin <branchname>: commits are uploaded to origin

git pull origin: updates and applies the changes to your local environment





Videos

An old but informative tech talk.

  • Fundamental ideas behind Git.
  • Comparison of Git with other similar systems.
  • Advantages of the distributed approach in version control systems.
  • Some best practices for using Git.

References

⚠️ **GitHub.com Fallback** ⚠️