- 19 years old
- a 2nd Year BS IT student
- currently studying at Mapua Malayan Colleges Laguna
- currently studying:
- Web Development
- MS Access
Here is a quick reference guide summarizing essential Git commands that is commonly used for efficient version control and collaboration within Git repositories.
1. git statusUsed to display the current state of the working directory and staging area.
Here is an example if the specified repository is empty, and there are untracked files that you might want to start tracking by using git add to include them in the next commit.
2. git init
Initializes a new, empty Git repository in the current directory to start tracking changes and manage versions of files. By default, running git init in a directory initializes Git in that directory itself.
To initialize a Git repository in a specific folder, a folder name must be given in this format: git init [name of the Folder].
Here is an example that initializes a new Git repository within a specified directory named 'folderName' inside the current directory (cscendaya).
3. git log
It is command that shows a version history of all the changes made to a project. It displays a history of saved snapshots (called "commits"), that can help track the evolution of the project development.
4. git clone [url]
Duplicates an entire repository, including all files, version history, and branches, from an online location (such as Github) to a local computer.
Here is an example of cloning an existing repository. (P.S: Link was copied from a Github repository)
5. git config --global user.name (or user.email)
Manages Git settings like your name, email, and other preferences. It helps you set up/check how Git works/operates on a computer or in a specific repository.
Some configurations are:
- git config <key> "<value>"
- <key> represents the configuration setting you want to modify or set
- "<value>" is the value you want to assign to that configuration setting
- git config --global init.defaultBranch main
- Set the default branch name for new repositories
- git config core.editor "code --wait"
- Set VS Code as default editor
6. git add .
employed to prepare all changes in the current working directory for the upcoming commit. This includes the addition of new files, modifications to existing files, and removal of files, staging them in the repository and making them ready to be included in the subsequent commit.
7. git push -u origin (branch)
employed to transmit local commits to a remote repository. Whenever modifications are made to the local repository and there is a need to distribute these changes to others or update a remote repository, the git push command is utilized.