Skip to content

Mehmet TEMİZEL Git Research

MEHMET_TEMIZEL_2015400075 edited this page Feb 17, 2020 · 2 revisions

Why a Version Control System like Git is needed

Real life projects generally have multiple developers working in parallel. So a version control system like Git is needed to ensure there are no code conflicts between the developers.

Additionally, the requirements in such projects change often. So a version control system allows developers to revert and go back to an older version of the code.

Finally, sometimes several projects which are being run in parallel involve the same codebase. In such a case, the concept of branching in Git is very important.

Some Basic Commands

git init - This command adds a local Git repository to the project.

git clone <url> - This command is used to clone an existing remote repository into your computer.

git status - This command shows which files are in which states. (modified, staged, unmodified)

git add - This command adds files to Git you want to track.

git add <path> - This command begins tracking the file or the directory in the given path. Also, you can use the same command to stage file.

git commit - This command commits the staging area. If you don't stage a file, after a commit, the file is still in the working directory as before.

git commit -a - This command skips the staging area and commits all the tracked files.

git commit -m - This command add README to initial commit.

git status - Use git status to find out information regarding what files are modified and what files are there in the staging area.

git diff - This command shows the difference between staged area and working directory.

git diff --staged - This command shows difference between staged area and last commit.

git rm <filename> - This command removes the file from the working directory and also from the index of Git.

git rm --cached <filename> - This command removes the file from Git, but the file is still in your working directory.

GitHub and the command line

For developers new to the command line, the GitHub Training team has put together a series of tutorials on Git commands to guide the way. Sometimes, a series of commands can paint a picture of how to use Git:

Example: Contribute to an existing repository 11 Example: Start a new repository and publish it to GitHub 22 Example: contribute to an existing branch on GitHub 33









Clone this wiki locally