0% found this document useful (0 votes)
2 views2 pages

GitCommands

The document outlines a series of Git commands used to create and manage a project repository. It includes commands for initializing a repository, creating and switching branches, staging and committing changes, and viewing the status and history of the repository. Key actions include creating a README file, merging branches, and appending content to the README.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

GitCommands

The document outlines a series of Git commands used to create and manage a project repository. It includes commands for initializing a repository, creating and switching branches, staging and committing changes, and viewing the status and history of the repository. Key actions include creating a README file, merging branches, and appending content to the README.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Used Git Commands (8/2/2024):

1. mkdir my_project: This command creates a new directory


named my_project.
2. cd my_project: This command changes the current directory
to my_project.
3. git init: This initializes a new Git repository in
my_project directory.
4. echo "# Example Project" > README.md: This creates a new
file named README.md with the content # Example Project.
5. git add README.md: This stages the README.md file for the
next commit.
6. git commit -m "Initial Commit with README": This commits
the staged changes with the message “Initial Commit with
README”.
7. git status: This shows the status of the working directory
and staging area.
8. git log: Displays the commit history for the repository,
showing details like commit hashes, authors, dates, and
commit messages.
9. git branch -a: Lists all branches in the repository,
including both local and remote branches.
10. git branch feature-branch: Creates a new branch
named feature-branch.
11. git checkout feature-branch: Switches to the feature-
branch.
12. git checkout -b new-feature: Creates and switches to a
new branch named new-feature.
13. git merge feature-branch: Merges the feature-
branch into the current branch (new-feature in this case).
14. echo "# Branch example" > README.md: Creates or
overwrites the README.md file with the content # Branch
example.
15. git add README.md: Stages the README.md file for the
next commit.
16. git commit -m "initial commit with README": Commits
the staged changes with the message “initial commit with
README”.
17. git checkout master: Switches the current working
directory to the master branch.
18. echo "master" >> README.md: Appends the text “master”
to the README.md file.
19. git add README.md: Stages the README.md file for the
next commit.
20. git commit -m "another message": Commits the staged
changes with the message “another message”

You might also like