Repository Operations
git init
git init
Initialize a new Git repository.
git clone
git clone [repository_url]
Clone (copy) the remote repository.
Basic operations
git add
git add [file]
git add .
Add the files to the staging area.
git commit
git commit -m "commit message"
Commit the changes in the staging area.
git status
git status
Displays the status of your working directory and staging area.
git log
git log
View the commit history.
git diff
git diff
Shows the differences between the working tree and the index.
Branch operations
git branch
git branch
git branch [branch_name]
View the current branch or create a new branch.
git checkout
git checkout [branch_name]
Switch branches.
git merge
git merge [branch_name]
Merge the specified branch into the current branch.
Remote Repository Operations
git remote
git remote -v
View the remote repositories.
git fetch
git fetch
Fetches changes from a remote repository but does not update your working tree.
git pull
git pull
Fetch the changes from a remote repository and merge them into your working tree.
git push
git push
Push the changes from your local repository to the remote repository.
Other useful commands
git stash
git stash
git stash pop
Temporarily shelve your current changes or revert shelved changes. Useful when working on multiple branches in parallel.
git rebase
git rebase [branch_name]
Rebase based on the specified branch.
git reset
git reset --hard [commit_hash]
git reset --soft [commit_hash]
Reset the commit (hard reset, soft reset).
git clean
git clean -f
Delete the untracked files.
Comments
Post a Comment