Showing posts with label Commands!. Show all posts
Showing posts with label Commands!. Show all posts

Monday, July 13

Git Essential Commands!

 Master Git with These Essential Commands! πŸ–₯️


1. Basic Git Commands

πŸ“Œ git init – Initialize a Git repository.
πŸ“Œ git clone <repo_url> – Clone a repository to your local machine.
πŸ“Œ git status – Check the current state of your repository.
πŸ“Œ git add <file> – Stage changes for commit.
πŸ“Œ git commit -m "message" – Save changes with a commit message.
πŸ“Œ git push – Upload local commits to a remote repository.
πŸ“Œ git pull – Download and merge changes from a remote repository.

2. Branching & Merging
πŸ“Œ git branch – List branches.
πŸ“Œ git branch <branch_name> – Create a new branch.
πŸ“Œ git checkout <branch_name> – Switch to another branch.
πŸ“Œ git checkout -b <branch_name> – Create and switch to a new branch.
πŸ“Œ git merge <branch_name> – Merge changes from another branch.

3. Remote Repository Management
πŸ“Œ git remote -v – View remote repositories.
πŸ“Œ git remote add <name> <url> – Add a remote repository.
πŸ“Œ git push origin <branch> – Push changes to a remote branch.
πŸ“Œ git pull origin <branch> – Pull changes from a remote branch.

4. Viewing & Comparing Changes
πŸ“Œ git log – View commit history.
πŸ“Œ git log --oneline – View a simplified commit history.
πŸ“Œ git diff – Show changes between commits or branches.
πŸ“Œ git blame <file> – Show who changed each line of a file.

5. Undoing Changes & Resetting
πŸ“Œ git reset --soft HEAD~1 – Undo last commit but keep changes staged.
πŸ“Œ git reset --hard HEAD~1 – Undo last commit and remove changes.
πŸ“Œ git revert <commit_id> – Revert changes without losing history.
πŸ“Œ git restore <file> – Undo changes in a file.

6. Stashing Changes
πŸ“Œ git stash – Temporarily save changes without committing.
πŸ“Œ git stash list – View saved stashes.
πŸ“Œ git stash pop – Apply the last stash and remove it.

7. Tags & Releases
πŸ“Œ git tag <tag_name> – Create a tag for a specific commit.
πŸ“Œ git tag -a <tag_name> -m "message" – Annotated tag with description.
πŸ“Œ git push origin --tags – Push all tags to the remote repository.

8. Git Hooks & Automation
πŸ“Œ git pre-commit – Runs scripts before a commit.
πŸ“Œ git post-commit – Runs scripts after a commit.
πŸ“Œ git pre-push – Runs checks before pushing to remote.

9. Handling Merge Conflicts
πŸ“Œ git mergetool – Open a merge conflict resolution tool.
πŸ“Œ git merge --abort – Cancel a merge.
πŸ“Œ git diff <branch_1> <branch_2> – Compare differences between branches.

10. Git & DevOps
πŸ“Œ git fetch --all – Fetch changes from all remotes.
πŸ“Œ git rebase <branch> – Reapply commits on top of another branch.
πŸ“Œ git cherry-pick <commit_id> – Apply a specific commit from another branch.

Git Essential Commands!

  Master Git with These Essential Commands! πŸ–₯️ 1. Basic Git Commands πŸ“Œ git init – Initialize a Git repository. πŸ“Œ git clone <repo_url...