Version control
version control is a system that records changes to files over time making it easier to track code, restore and collaborate safely.
Git
Git is a distributed version control system used for code collaboration, code restoration, tracking code changes and who made them.
Git commands
git --version

git --version checks whether git is installed on your computer and what version is installed.
git config --user.name"yourname"

git config --user.name"yourname" sets the author's name linked to the commits.
git config --user.email"youremail"
git config --user.email"youremail" sets the email address linked to your commits.
git config --list

git config --list shows all git configuration settings currently applied to the system.
ls ~/.ssh
ls ~/.ssh looks for SSH folder in the home folder.
ssh-keygen -t ed25519 -C"youremail"
--
ss-keygen -t ed25519 -C"youremail" generates private and public SSH keys.
eval "$(ssh-agent -s)"

eval "$(ssh-agent -s)" starts the ssh agentand sets the necessary environment variables in the current terminal session.
--unset
--unset is used to remove a setting.
ssh-add ~/.ssh/id_ed25519
ssh-add ~/.ssh/id_ed25519 allows git to use your key automatically without asking for the passphrase every time.
git init
git init creates a hidden .git folder that git uses to track changes.
git add .

git add . tells git to stage all changes in the current directory and its sub directories so they are ready to be committed.
Push commands.
git push
git push is used to send local commits to a remote repository.
git push -u
git push -u is used to push the current branch and set its tracking branch.
git push --all
git push --all pushes all the local branches to the remote directory.
git push --tags
git push --tags pushes all the local git tags to the remote repository.
git push --force
git push --force forces the local branch to overwrite the local branch.
pull commands.
git pull
git pull gets changes from a remote repository and merges them into the current branch.
git pull origin main
git pull origin main fetches the latest changes from the remote origin and merges the main branch into the current local branch.
git pull --rebase
git pull --rebase updates the branch by replaying the local commits on top of the latest remote commit.
git fetch
git fetch downloads the latest changes from a remote repository without modifying the local branches.
git fetch --all
git fetch --all fetches updates from all remotes without changing the local branches.
git pull --ff
git pull --ff tells git to update the branch using a fast forward merge only.
git fetch
git fetch downloads the latest changes from a remote repository without changing the local branches.
git fetch --all
git fetch -- all fetches updates from all every remote without changing the local branches.
Creating directory commands
mkdir
mkdir is a command used to create a new directory.
mkdir -m
mkdir -m is used to create a directory and set its permission at the same time.
mkdir -p
mkdir -p creates a directory and any missing parent directories.
cd
cd (change directory) is used to navigate into a git repository before running git commands.
cd ~
cd ~ moves you to the home folder.
cd -
cd - takes you back to the previous directory you were in.
cd /
cd / command moves you to the root directory of the file system.
cd "my folder"
cd "my folder" is used to change into a directory whose name contains spaces.
Tracking changes
git status
git status shows the current state if the working directory and staging area.
git diff
git diff is used to see the exact changes between files, commits, branches or stages in git.
git log
git log is used to view the commit history of a git repository. what was committed by whom and when.
git blame
git blame is used to see who last modified each line of a file, when, and in which commit.
git show
git show is used to display details of a git object. It lets you see what changed who changed it and when.



Top comments (0)