GIT Bash Commands
GIT Bash Commands
Cloning a Repository
To clone a repository from a remote server (like GitHub), use the git clone command
followed by the URL of the repository:
Once you have cloned the repository, you can navigate into the repository's directory using cd
<repository_name> if you're not already there.
To check the current status of your repository (e.g., modified files, untracked files), use:
git status
To stage files for the next commit (prepare files to be included in the next commit), use:
Committing Changes
Replace "Commit message here" with a brief, descriptive commit message summarizing
your changes.
To push committed changes to the remote repository (typically where you cloned from):
git push
If it's your first push or if you are pushing to a new branch, you might need to set the upstream :
git pull
git log
● Undoing Changes: To discard changes in your working directory:
git checkout -- <file_name> # Discard changes in a specific file
● This should give you a good starting point with Git Bash for typical repository
interactions. Adjust commands based on your specific repository workflow and needs.
● Delete Branch: To delete a branch (only if it's fully merged into another branch):
git branch -d <branch_name>
● Merge Branch: To merge another branch into your current branch:
git merge <branch_name>
● Working with Remote Repositories
Fetch: To fetch changes from the remote repository without merging:
git fetch
● Revert: To create a new commit that undoes changes made to a specific commit:
git revert <commit_hash>
● Inspecting Changes
Diff: To show changes between commits, commit and working tree, etc.:
git diff # Show changes between the index and working tree
git diff <commit> # Show changes between the index and specific
commit
● Tagging
Tag: To create, list, delete, or verify a tag object signed with GPG:
git tag # List tags
git tag <tagname> # Create a tag
These commands cover additional functionalities and scenarios you might encounter while
using Git. Depending on your specific workflow and needs, you may find yourself using these
commands frequently to manage and collaborate on your projects effectively.