0% found this document useful (0 votes)
6 views

Git Commands

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Git Commands

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

GIT COMMANDS

Git is a distributed version control system designed to manage source code

changes efficiently and effectively. Git allows multiple developers to

collaborate on projects while maintaining a complete history of changes. Its

core features include:

• Version Control: Git tracks changes to files, allowing you to revert to

previous versions, compare changes, and understand the evolution of a

project.

• Branching and Merging: Developers can create branches to work on features

or bug fixes in isolation. Once changes are complete, branches can be

merged back into the main project, facilitating parallel development.

• Distributed Architecture: Unlike centralized version control systems, Git

allows every developer to have a complete copy of the repository, enhancing

collaboration and making it possible to work offline.

• Performance: Git is optimized for speed, making operations like committing

changes, branching, and merging extremely fast.

• Collaboration: With Git, multiple developers can work on a project

simultaneously, with tools like GitHub and GitLab enabling easy sharing and

collaboration on code.

1. git init: Initializes a new Git repository in the current directory.

2. git clone <repository_url>: Creates a local copy of a remote repository.

3. git add <file_name>: Adds a specific file to the staging area.

4. git add .: Adds all files in the current directory to the staging area.

5. git status: Displays the status of changes in the working directory and staging

area.

6. git commit -m "message": Commits the staged changes to the repository with a
descriptive message.

7. git log: Shows the commit history, including details about each commit.

8. git show <commit_id>: Displays the details of a specific commit.

9. git rm <file_name>: Deletes a file from the working directory and stages the

removal for commit.

10. git checkout -- <file_name>: Discards changes to a file that have not been

staged.

11. git branch <branch_name>: Creates a new branch for development.

12. git checkout <branch_name>: Switches to the specified branch.

13. git branch: Lists all local branches in the repository.

14. git merge <branch_name>: Merges changes from the specified branch into the

current branch.

15. git branch -d <branch_name>: Deletes the specified branch.

16. git merge --abort: Aborts a merge process if there are conflicts.

17. git push origin main: Pushes committed changes to the remote repository on the

specified branch.

18. git pull: Fetches and merges changes from the remote repository into the current

branch.

19. git fetch: Retrieves updates from the remote repository without merging them.

20. git stash: Temporarily saves uncommitted changes in a "stash" to clean the

working directory.

21. git cherry-pick <commit_id>: Applies the changes from a specific commit to the

current branch.

You might also like