GIT - ossarioglu/SWE573-repo GitHub Wiki

What's GIT and what are its functions?

GIT is defined as distributed version control system, allowing users to track changes through development process of a project. Different users can access these version at the same time, and make updates aligned to each other.

Configuration: In order to use git at your computer, you need to install it. You can find suitable git version here. After you install it, you can use your terminal for git commands.

Initialization and Check Status: You need repositories to work with git. Repositories are some kind of containers having files of your git. init command enables you create an empty repository. A hidden folder ".git" is created when you run this command. If you want to see what's the status of your repository, you can use status command for this.

   git init
   git status

Staging and Committing: Whenever you make a change on your files in repository, you can see this modified files with status command. If you want to make these changes applied in your work, first you need add these work into your git. This is called staging. This means you are actively working those files. After your work is done, you need to commit your progress with commit command, then a "commit" object is created with a unique id. This ID is combination of content, author, date, log, and previous commitment.

Previous commitments is not changed when new commitments are created, and you can jump into any previous commitment to see previous versions of job done. You can do this with checkout command.

   git add "file_name"                      : Add "file_name" into git
   git add .                                : Add all modified files into git
   git commit -m "Your message"             : Commits the change on the active timeline (branch) with a unique id
   git checkout "Commitment_ID"             : Load mentioned committed versions of files

Branches: You can think branches as new timelines for development. When you initialize a git, you have "master" as a default timeline/branch. Since git enable multiple users to work collaboratively and simultaneously on the same project, some users may want to change on code without affecting others work. This is possible with creating new branches and committing the changes on these branches without affecting others work on other branches. You can use branch command for these actions.

In order to select in which branch you want to progress, you need to use checkout command. This enables you to track your progress on the selected branch, and any new commitments are related into this path.

   git branch                               : List branches in the git
   git branch "branch_name"                 : Create a new branch with "branch_name"
   git checkout "branch_name"               : Add "file_name" into git

Merging: When you make progress on different branches you need to combine this work, and commit the updates as a whole product. In order to do this activity, you apply merge command. After commitment, last commitment is flagged with target branch name.

   git merge "branch_to_merge" "target_branch"

Resources:

Git Tutorial For Dummies
Learn Git In 15 Minutes
Git For Ages 4 And Up