Welcome to Top-18 Command
!
The command below returns a list of information about your git configuration including user name and email:
git config -l
This command lets you setup the user email address you'll use in your commits.
git config --global user.email "[email protected]"
You can store login credentials in the cache so you don't have to type them in each time. Just use this command:
git config --global credential.helper cache
Everything starts from here. The first step is to initialize a new Git repo locally in your project root. You can do so with the command below:
git init
The command below will add a file to the staging area. Just replace filename_here with the name of the file you want to add to the staging area.
git add filename_here
If you want to add all files in your project to the staging area, you can use a wildcard . and every file will be added for you.
git add .
With the asterisk in the command below, you can add all files starting with 'fil' in the staging area.
git add fil*
This command will show the status of the current repository including staged, unstaged, and untracked files.
git status
This command will open a text editor in the terminal where you can write a full commit message.
A commit message is made up of a short summary of changes, an empty line, and a full description of the changes after it.
git commit
You can add a commit message without opening the editor. This command lets you only specify a short summary for your commit message.
git commit -m "your commit message here"
You can add and commit tracked files with a single command by using the -a and -m options.
git commit -a -m"your commit message here"
This command shows the commit history for the current repository:
git log
This command shows the commit's history including all files and their changes:
git log -p
git revert will create a new commit that is the opposite of everything in the given commit. We can revert the latest commit by using the head alias like this:
git revert HEAD
When you want to use a different or a newly created branch you can use this command:
git checkout branch_name
You can view all created branches using the git branch command. It will show a list of all branches and mark the current branch with an asterisk and highlight it in green.
git branch
If you no longer need a remote branch you can remove it using the command below:
git push --delete origin branch_name_here