Hey there, here is the Git cheatsheet with the most important and commonly used Git commands and also you can Download the PDF of this cheatsheet from the link given below for FREE 🤩
Git Basics
1. Initialize a Repository
It is used to initialize a new Git repository in the current directory.
2. Clone a Repository
This command is used to create copies of a remote repository to your local machine.
Also Read: 50 HTML Tags and their functions with Example: Click Here
3. Check Repository Status
This git command shows the status of changes as untracked, modified, or staged of a repository.
4. Stage Changes
This command adds specified file changes to the staging area.
5. Commit Changes
This git command records staged changes with a descriptive message.
6. View Commit History
This git command is used to display a chronological list of commits.
Branching and Merging
1. Create a New Branch
This git command is used to creates a new branch.
2. Switch to a Branch
This git command is used to moves to the specified branch.
or, in newer Git versions
3. Merge Branches
This command combines changes from the specified branch into the current branch.
Also Read: 50 HTML Tags and their functions with Example: Click Here
4. Delete a Branch
This git command deletes the specified branch.
Remote Repositories
1. Add a Remote Repository
This git command links a remote repository to your local repository.
2. Fetch Changes from a Remote
It retrieves changes from a remote repository without merging.
3. Pull Changes from a Remote
This git command fetches changes and merges them into the current branch.
4. Push Changes to a Remote
This command is used to upload local branch changes to the remote repository.
Undoing Changes
1. Discard Uncommitted Changes
It is used to discard changes in the working directory.
2. Undo the Last Commit (keep changes)
This git command undoes the last commit while keeping changes staged.
To discard changes:
3. Revert a Commit
This command creates a new commit that undoes the changes of a previous commit.
Miscellaneous
1. Configure Git
It is used to set your global Git username.
It sets your global Git email.
2. Ignore Files
Create a '.gitignore' file and list files/directories to be ignored.
3. Stash Changes
This git command temporarily save changes that are not ready to be committed.
To apply stashed changes:
Restores the latest stashed changes.
Also Read: 50 HTML Tags and their functions with Example: Click Here
I hope this Git cheatsheet will be helpful for you. And you will defiantly enjoy this and also you will use it as reference while building projects. So you can now download PDF of this Git cheatsheet from the link given below 👇🏻