-
Notifications
You must be signed in to change notification settings - Fork 3
Git Tutorial
Git is a version control system (the practice of tracking and managing changes to software code) . It is used for
- Tracking code changes
- Tracking who made changes
- Coding collaboration
Git might already be installed on your Linux/WSL computer. You can check it via the command git --version
.
If it is not installed yet, you may install via the command sudo apt install git
.
In order to configure git, use the commands git config --global user.name "alice-spring"
and git config --global user.email "[email protected]"
for the name and e-mail, respectively.
In the directory that you want to use the Git source control, use the git init
command, and Git will be initialized.
Imagine that in a project, you have written a file with a code called hello.py
and you are sure that this file is in the directory that you have already initialized Git. In such cases, use git status
to see whether a file is a part of the repository. See Git does not add the file git status
, but it is aware of that file in the directory.
To add a file into the Staging Environment (for ready-to-commit files) of Git, one has to type git add hello.py
. In this case, hello.py
is added to the Staging Environment, which you should add the files to it when you hit a milestone or finish a part of the work. Instead of adding each file one-by-one, git add --all
would add all individual filenames, and will stage all changes (new, modified, and deleted files).
Probably "committing" is the most popular term in the Git universe. Git considers each commit change point or "save point", By adding clear messages to each commit, it is easy for yourself (and others) to see what has changed and when. The commit command performs a commit, and the -m "message" adds a message. For instance, git commit -m "First release of hello.py"
is a valid Git commit. To make commits later, type a command like git commit -a -m "Updated hello.py with a new line"
, where the -a option will automatically stage every changed, already tracked file.
To view the history of commits for a repository, you can use the log command (git log
).
Any time you need some help remembering the specific option for a command, you can use git _commandname_ -help
(In the case of commit command, type git commit -help
). To list all possible commands, use the git help --all
command, but keep in mind that this will display a very long list of commands.
Branching in Git is also made by its specific command. Suppose one wishes to create a new branch called "hello-world-images". He/she has to type git branch hello-world-images
. Moving among branches is performed via git checkout hello-world-images
The file names such as hello.py
, and the name-surname-emails are given as an example and does not reflect any real files, people, or e-mail address. For further questions or explanations, feel free to contact!
-
📝 Plan
-
📝 Project
-
📝 Customer Milestone Reports
-
✨ Team Members
-
📋 Templates
Cmpe 352 Archive
-
🔍 Researches
-
📝 Project