Git, Commands Cheat Sheet
Glossary
- Git: A distributed version control system designed for tracking changes in source code during software development
- Repository(repo):A data structure that stores metadata and objects for a Git Project, includes files, commit history, branches, and configuration settings
- Commit: A snapshot of changes made to files in a repository at a specific point in time.
- Staging: Preparing files before being committed to the repository. Staged files are the ones ready to be included in the next Commit
- Branch: A branch allows developers to work on separate features or fixes in a parallel manner without affecting the main code base
- Push: the action of uploading local commits from your local repository to a remote repository such as GitHub or GitLab or your own or your company’s hosted repositories.
- Pull: The action of fetching the changes from a remote repository and merging them with your local repository.
- Merge: The process of integrating changes from one branch into another branch
- Conflict: A situation where Git cannot automatically merge changes from different branches due to conflicting modifications to the same file.
- Clone: The action of creating a local copy of a remote repository to your machine
COMMONLY USED COMMANDS
1
git clone [url]
Retrieve an entire repository from a remote/hosted location via URL
1
git status
Show which files are modified, untracked or staged commit.
1
2
git add [file]
git add .
Adds the changes in a specific file(add [file]
) or all modified files(add .) in the working directory or the staging area, preparing them for the next commit.
1
git commit -m "[commit message]"
Commits the staged changes to the local repository with a descriptive commit message explaining the changes made
1
git push
Pushes the committed changes from your local repository to the remote repository, keeping them synchronized.
1
git pull
Fetches changes from the remote repository and merges them to your local repository
1
git checkout [branch name]
Switches to the specific branch.
1
git merge [branch name]
Merges changes from the specified branch into the current branch
1
git log
Displays a chronological list of commits in the repository along with the messages, authors, timestamps, and commit IDs.
source: github.com
SETUP & INIT
1
git config --global user.name "[firstname lastname]"
set a name that is identifiable for credit when review version history \
1
git config --global user.email "[valid-email]"
set an email address that will be associated with each history maker
1
git config --global color.ui auto
set automatic command line coloring for Git for easy reviewing
1
git init
initialize an existing directory as a Git repository
1
git clone [url]
retrieve an entire repository from a remote/hosted location via URL
STAGE & SNAPSHOT
1
git status
Comments powered by Disqus.