Professional Documents
Culture Documents
After filling in all necessary information, remember to switch to private mode to protect source code
and data from unauthorized access. This ensures safety and efficient management for the project.
Upon completing these steps, there will be a repository on your GitHub account with an interface like
this.
1.5 Git Bash: Connecting for Windows Users:
If using Windows: Git Bash is included as part of the Git For Windows package. Download
and install Git For Windows like installing other Windows applications. After downloading,
locate the accompanying .exe file and open it to run Git Bash.
Eventually, when opening the terminal, there will be a bash to easily use Git commands. (In
this case, it's macOS.)
2. Clone Repository to Your Computer:
Note*: There is an important distinction between cloning private projects and public projects on
GitHub or similar version control systems. Below are some key points to note:
Private project: Cloning a private project requires authentication, usually through the use of
SSH keys or username/password.
Therefore, you need to create SSH keys on your account to use commands like this:
After obtaining the SSH link from within your private repo, you can clone this project using
the command:
git clone <ssh>
(Image after successful cloning)
About the application of the .gitignore file, there will be sections after starting to use git add,
git commit, git push, or git pull.
5. Git init, git add, git commit, git push, git pull Commands:
Git init:
Git init is a command in Git used to initialize a new Git repository. When you run this
command in an empty directory, it creates a new repository and starts tracking changes in
your project. Below are the meanings of git init:
_ Create a New Git Repository
_ Start Tracking Changes
_ Create a Git Working Directory
_ Prepare the Project for Version Control
*Note: If you copy a repository from GitHub using git clone, you don't need to run git
init again. The git clone command automatically initializes a new Git repository for you.
When you run git clone, it will:
_ Create a new directory with the same name as the repository being copied.
_ Initialize a new Git repository in that directory.
_ Fetch the contents of the repository from remote (from GitHub in this case) and set up a
working copy locally.
Git add:
In Git, the git add command is used to add changes from the working directory to the staging
area to prepare for committing. This command plays an important role in the Git workflow.
Syntax:
Add a Specific File:
git add <file> (File in this case can be a single file or a directory)
Add all changes:
git add .
In this case, using git add . adds file1.txt to the src. Using git add . will add both file1.txt and
.gitignore to the staging area to prepare for commit. Use the git status command to observe
the working status and status of files.
Git commit:
The git commit command in Git is used to save the changes from the staging area to the
version history of the repository. Each commit corresponds to a record in the history,
preserving the state of the project at that time. Below is how to use git commit:
Git push:
The git push command in Git is used to push commits (committed changes) from your local repository
to the repository on the server (remote repository), usually on services like GitHub, GitLab, or
Bitbucket. Below is how to use git push:
Syntax:
remote name: The name of the remote repository you want to push to. Usually origin if you
have cloned from a remote repository.
branch_name: The name of the branch you want to push to. In this case, it's main.
Result: At this point, your repository on GitHub has been changed, and the main
branch has a new commit added.
Optional: Using git push -u and setting up upstream relationships, you can use git push
without specifying the remote repository name and branch name because Git already knows
which branch on the remote repository corresponds to your local branch.
Syntax: git push -u origin main
Git pull:
The git pull command in Git is used to update your project with the latest changes from the remote
repository. It is equivalent to running git fetch to download data from the remote repository and then
git merge to merge the changes into your local branch.
Syntax:
git pull [remote_name] [branch_name]
Ghi chú:
If there are no conflicts between your local changes and changes from the remote repository,
Git will automatically merge the changes.
If there are conflicts, Git will pause and allow you to resolve the conflict before completing
the merge.
If you have cloned the initial repository with git clone, you may not need to specify remote
and branch names because default values (usually "origin" and "main" or "master") have been
set during cloning.
Always ensure you have committed or stashed local changes before performing the pull
command to avoid conflicts.
Each object created from a class will have the attributes and methods of that class. This
helps organize the source code clearly, makes it easy to maintain, and increases code
reuse.
Properties: are the attributes of the class (in this case, name and age).
And Methods are the functions that the class can perform. For example, bark here.
After initializing the my_dog object belonging to the dog class, we give this object the
attributes of the dog class with the name "Buddy" and age "3". Now my_dog can
perform the methods of the dog class, such as bark.