Journey to master your git skills (Beginners)
Let us take a journey together. By the end of the article, you would have mastered all the basic necessary skills required for a software engineer with version control.
Create a empty directory and initialize with git:
mkdir new_project cd new_project git init
This would have created a hidden directory
config file inside it. For now, we will not create a remote repo or link the local will any remote origin. This will be cover as part of next tutorial in this series.
To get the current state of the repo, use the commands below. It gives out detailed name and status.
git branch -vvv git status
If the branch is having changes (both 'staged' and 'unstaged'), it can be either flushed or saved in a stash. In case staged changes, do
git restore --staged .
git restore .
But if we would like to save the changes, it is better to stash them:
git stash list git stash push --include-untracked -m 'stash message'
To retrieve those changes, we can:
git stash apply 1 # or git stash pop
in case any untracked files and directories are present, it cannot be removed by
restore command. It can be done using:
git clean -fd
Now, switch to
main and ensure that the local is having all the commits. Create a new branch from the base branch:
git checkout main git fetch -a git pull --rebase origin main git checkout -b dev/feature-name
git reset --soft HEAD~2 git restore --staged .
git reflog git reset 293da63
Debugging git connectivity issues:
git remote -v