You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
5. How to initialize a Git repo:
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
6. How to add a file to the staging area in Git:
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
7. How to add all files in the staging area in Git
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 .
8. How to add only certain files to the staging area in Git
With the asterisk in the command below, you can add all files starting with 'fil' in the staging area.
git add fil*
9. How to check a repository's status in Git:
This command will show the status of the current repository including staged, unstaged, and untracked files.
git status
10. How to commit changes in the editor in Git:
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
11. How to commit changes with a message in Git:
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"
12. How to commit changes (and skip the staging area) in Git:
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"
13. How to see your commit history in Git:
This command shows the commit history for the current repository:
git log
14. How to see your commit history including changes in Git:
This command shows the commit's history including all files and their changes:
git log -p
15. How to see a specific commit in Git:
This command shows a specific commit.
Replace commit-id with the id of the commit that you find in the commit log after the word commit.
git show commit-id
16. How to see log stats in Git:
This command will cause the Git log to show some statistics about the changes in each commit, including line(s) changed and file names.
git log --stat
17. How to see changes made before committing them using "diff" in Git:
You can pass a file as a parameter to only see changes on a specific file.
git diff shows only unstaged changes by default.
We can call diff with the --staged flag to see any staged changes.
git diff
git diff all_checks.py
git diff --staged
18. How to see changes using "git add -p":
This command opens a prompt and asks if you want to stage changes or not, and includes other options.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Tech-Solutions-Cheat-Sheet
All technical Solution under one umbrella
Git cheat sheet with 50 plus commands line examples you should learn
Anwar Hossain
Data Scientist | Statistician | Quantitative Researcher | Content Creator
Subscribe my Youtube Channel: http://facebook.com/anwar.datascientist
Follow me on Facebook: http://facebook.com/anwar.datascientist
Follow me on Twitter: http://twitter.com/anwar_stat
Follow me on Instragram: http://facebook.com/anwarstatjnu
Follow me on LinkedIn: http://facebook.com/anwarstat
Follow me on Github: http://facebook.com/anwarstat
1. How to check your Git configuration:
The command below returns a list of information about your git configuration including user name and email:
2. How to setup your Git username:
With the command below you can configure your user name:
git config --global user.name "your-user-name"
3. How to setup your Git user email:
This command lets you setup the user email address you'll use in your commits.
git config --global user.email "your-email@domain.com"
4. How to cache your login credentials in Git:
You can store login credentials in the cache so you don't have to type them in each time. Just use this command:
5. How to initialize a Git repo:
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:
6. How to add a file to the staging area in Git:
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.
7. How to add all files in the staging area in Git
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 .
8. How to add only certain files to the staging area in Git
With the asterisk in the command below, you can add all files starting with 'fil' in the staging area.
git add fil*
9. How to check a repository's status in Git:
This command will show the status of the current repository including staged, unstaged, and untracked files.
10. How to commit changes in the editor in Git:
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.
11. How to commit changes with a message in Git:
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"
12. How to commit changes (and skip the staging area) in Git:
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"
13. How to see your commit history in Git:
This command shows the commit history for the current repository:
14. How to see your commit history including changes in Git:
This command shows the commit's history including all files and their changes:
15. How to see a specific commit in Git:
This command shows a specific commit.
Replace commit-id with the id of the commit that you find in the commit log after the word commit.
16. How to see log stats in Git:
This command will cause the Git log to show some statistics about the changes in each commit, including line(s) changed and file names.
17. How to see changes made before committing them using "diff" in Git:
You can pass a file as a parameter to only see changes on a specific file.
git diff shows only unstaged changes by default.
We can call diff with the --staged flag to see any staged changes.
18. How to see changes using "git add -p":
This command opens a prompt and asks if you want to stage changes or not, and includes other options.
Beta Was this translation helpful? Give feedback.
All reactions