Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

1.

git init: Initializing a Git repository/creating a repo locally on your computer

2. Add files to the staging area:


● git add <file_name>: To add a specific file
● git add . : To add all files

// The staging area is where you’ve acknowledged the changes made to the files, but they are
not yet committed.

3. git status: Returns the list of all changes that have been made in the project, including
the staged changes.

4. git commit -m "message": move the changes from the staging area to commit.

5. git log: Displays your commit history.

6. git show <commit_id>: Each commit has an ID attached(see details of commit)

7. git rm <file_name>: Deletes a file from your project folder. You need to provide a
message explaining why you want to delete it.

8. git checkout -- <file_name>: If you made changes to a file but haven’t staged them
(git add .), you can discard those changes and revert to the latest commit.

9. git branch <branch_name>: You usually have a main/master branch. However, you
can create a new branch to work on and later merge it with the main branch when you’re
done.

10. git checkout <branch_name>: This is how you switch to the branch you newly created.

11. git branch: Lists all the branches that you have created.

12. git merge <branch_name>: Merges the history of the current branch with the specified
branch.
13. git branch -d <branch_name>: Deletes a branch in Git.

14. git merge --abort: Sometimes merging branches can result in conflicts. This command
aborts the current merge process and allows you to start afresh.

15. git push origin main: This command is used to push the committed changes to the
remote repository. The changes will now be visible on GitHub where you created your
repo.
16. git pull: If you’re working with someone else on a project, you will need to pull the
changes they made before pushing any code.

You can always use these commands and if something wrong or unexpected happens, just GPT
the error that you see on terminal and you’ll know the next command to run on your terminal.

You might also like