A customized guide to everyday Git commands and GitKraken.
- Setting Up Git and GitKraken
- Creating and Initializing a Git Repository
- Staging and Committing Changes
- Using GitKraken to Enhance Your Workflow
- Working with Branches
- Pushing and Pulling Code to GitHub
- Merging and Resolving Merge Conflicts
- Using AI Features in GitKraken
- Additional GitKraken Features
- Advanced Git Operations
- Emergency Fixes
- Quick Reference
- Troubleshooting
- Examples in This Repo
Before we begin, ensure you have the following installed on your system:
- Git: Download from Git Official Site
- GitKraken: Free to use; download it from GitKraken Official Site
To begin using Git in your development environment, first download and install Git. Follow these steps:
Go to the Git Downloads page and select the appropriate version for your system (Windows, Mac, or Linux).
After installation, verify Git is installed by opening a terminal and typing:
git --versionNext, install GitKraken, a graphical interface for Git that makes managing repositories much easier. Download from GitKraken Official.
Create a new project folder or open your existing project in VS Code.
Open your terminal and navigate to your project folder. Type:
git initThis will initialize an empty Git repository in your project folder.
After initializing your repository, add files to Git:
Create or edit a file (e.g., index.html) in your project.
Stage the file to Git by typing:
git add index.htmlOr stage all files:
git add .Commit your changes:
git commit -m "Add index.html file"GitKraken helps visualize commits, branches, and changes. Here's how to get started:
- Download and install GitKraken.
- Log in with your GitHub account.
- Open your repository in GitKraken to see all your commits visually.
In Git, branches allow you to work on different features without affecting the main codebase.
To create a new branch, use:
git switch -c <branch-name>Or in GitKraken, click Create Branch and enter the branch name.
Switch branches to work on different features:
git switch <branch-name>To push your changes to a remote repository, first create a GitHub repository. Then, add the remote repository URL:
git remote add origin <repository-url>
git push -u origin masterTo pull changes from GitHub:
git pull origin masterWhen working with multiple branches, you may need to merge them. Here's how to do it:
Checkout the branch you want to merge into (usually master):
git switch masterMerge the feature branch into master:
git merge <feature-branch>If there are conflicts, GitKraken helps you resolve them visually. You can accept incoming changes, keep the current changes, or merge both manually.
GitKraken offers AI-assisted commit message generation and commit reorganization, making it easier to maintain clean and efficient commit histories. For example, you can use AI to generate meaningful commit messages or recompose multiple commits into one.
GitKraken is packed with powerful features to enhance your Git workflow beyond the basics. Here are some key ones:
Easily reorder, edit, or squash commits with a visual drag-and-drop interface. This helps clean up your commit history before merging.
Quickly search and navigate through your repository files, commits, and branches using fuzzy matching.
Handle large files efficiently with Git Large File Storage integration, keeping your repository lightweight.
Create, review, and merge pull requests directly within GitKraken, integrated with GitHub, GitLab, and Bitbucket.
Link commits to issues and track progress on projects with built-in issue management.
View a chronological timeline of your repository's activity, including commits, merges, and branch creations.
Switch between different Git identities and configurations for personal and work projects.
Connect with various tools like Jira, Trello, Slack, and more for seamless project management.
Customize the interface with dark mode or various themes for comfortable coding sessions.
Manage and visualize Git hooks to automate tasks like pre-commit checks or post-merge actions.
These features make GitKraken a comprehensive tool for both beginners and advanced users, streamlining complex Git operations.
If you have too many commits, combine them into one for a cleaner history:
git reset --soft HEAD~<number-of-commits>
git commit -m "combined message"
git push --forceCopy a specific commit from another branch:
git log # Find the commit hash
git cherry-pick <commit-hash>Update your branch without a merge commit:
git pull --rebaseIf conflicts arise:
- Fix the conflicts
- Stage the files:
git add <files> - Continue:
git rebase --continue - Push:
git push --force
To abort: git rebase --abort
Undo a commit safely by creating a new commit that reverses it:
git revert <commit-hash>
git pushMake your branch identical to another (destructive):
git reset --hard origin/<other-branch-name>Warning: This deletes all uncommitted changes!
Delete the last few commits:
git reset --hard HEAD~<number-of-commits>
git push --forceWarning: This cannot be undone!
Use the reflog to find and restore deleted commits:
git reflog
git cherry-pick <commit-hash># Check status
git status
# Stage and commit all changes
git add .
git commit -m "message"
git push
# Pull latest changes
git pull
# Create and switch to a new branch
git switch -c <branch-name>
# Switch branches
git switch <branch-name>
# Undo all changes
git restore .
# Stash work temporarily
git stash
git stash popWhen your branch has diverged from the remote:
git pull --rebaseResolve manually:
- Edit the conflicting files
- Remove conflict markers (
<<<<<<<,=======,>>>>>>>) - Stage:
git add <file> - Continue:
git merge --continue
- Verify your credentials
- Ensure you have access to the repository
This is my personalized Git guide with GitKraken integration!





