Git - bounswe/bounswe2024group8 GitHub Wiki

Introduction

Git is a free and open-source version control system that can be used by programmers for coordinating work while collaboratively developing software. It mirrors the complete codebase (and its full history) on each developer's computer, and tracks changes whenever a programmer makes a change. Git is the most popular version control system used by developers around the globe, with around 95% of developers reporting it as their primary version control system.

Git can be downloaded from its official webpage here: https://git-scm.com/downloads

Useful Commands

  • Convert an existing local directory to a Git repository: git init
  • Clone a Github repository to a local directory: git clone [Github url]
  • Get history of the current branch: git log
  • Snapshot a file so that it can be versioned by Git: git add [file]
  • Record all file snapshots in permanent version history: git commit -m "[commit message]"
  • Create new branch: git branch [branch-name]
  • Switch to another branch: git checkout [branch-name]
  • Delete a branch: git branch -d [branch-name]
  • Download all changes from remote branches: git fetch
  • Combine remote branch into current local branch: git merge
  • Upload all local branch commits to Github: git push
  • Update the current local branch with all changes on the remote branch: git pull
  • Revert to a commit and discard all history after that commit: git reset --hard [commit]

References / More Info