Category Archives: Uncategorized

GIT ADD . (ALL)

git add . is a Git command used to stage all changes made to a working directory, before committing them.

Here is an example:

Suppose you made changes to two files named file1.txt and file2.txt. You want to include both changes in your next commit.
To do so, first navigate to the project directory in the terminal and execute:

git add .

This command stages all of the changes made in repository. You can now review the changes staged by executing:

git status

You should see that file1.txt and file2.txt have been staged.
Now you can commit the staged changes by running:

git commit -m "Added new feature to file1.txt"

The commit will include all changes.

GIT CLONE

git clone is a command that creates a copy of a repository, including all its branches and history, in a new directory.

Here’s an example:

git clone https://github.com/username/repo.git

This will create a copy of the repository repo owned by username on GitHub, and save it to a new directory called repo in your local machine.

You can also use git clone to clone a repository from a remote server using SSH, or to clone a specific branch.

For more information, you can check out the official Git documentation.

GIT STATUS

The git status command displays information about the current status of the working directory and staging area in your Git repository. It tells you which files are currently being tracked, which changes have been staged, and which changes still need to be staged.

Let’s say you’re working on a new feature for your website and you’ve made some changes to your code. You can use git status command to see which files have been edited on your local copy:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout --<file>..." to discard changes in working directory)
        modified:   index.html

no changes added to commit (use "git add" and/or "git commit -a")

In this example, Git is reporting that the index.html file has been modified but not yet staged. This means that Git is aware of the changes you have made, but they have not yet been added to the next commit.

I hope that helps! Let me know if you have any other questions.

GIT COMMIT

The git commit command is used in Git to save changes to a local repository. It creates a new commit object with a unique identifier based on the changes made, along with a message that describes the changes. This allows you to keep track of changes made to your code over time and makes it easy to revert to previous versions if necessary.

Here’s an example of how to use git commit:

  1. After making changes to your files, add them to the staging area with git add.
  2. Once you’ve added all the changes you want to commit, run the git commit command followed by a -m flag and a message inside quotes describing the changes made. For example:
git commit -m "Added new feature to login page"

  1. The commit is now saved to your local repository with a unique identifier, allowing you to easily track and revert to previous versions of your code.

It’s important to note that committing changes locally only saves them to your local Git repository. To share the changes with others or push them to a remote repository, you’ll need to run git push after committing.


Here are some links that you may find helpful:

GIT ADD

git add is a Git command used to stage changes made to a working directory, before committing them. Staging is an intermediate step that allows you to control which changes are included in the next commit and which are not.

Here is an example:

Suppose you made changes to two files named file1.txt and file2.txt. You want to include the changes to file1.txt in your next commit, but not the changes to file2.txt.
To do so, first navigate to the project directory in the terminal and execute:

git add file1.txt

This command stages the changes made to the file file1.txt. You can now review the changes staged by executing:

git status

You should see that file1.txt has been staged.
Now you can commit the staged changes by running:

git commit -m "Added new feature to file1.txt"

The commit will include only the changes to file1.txt since file2.txt was not staged.

GIT LOG

git log is a command in Git used to display the commit history of a repository. When run, it shows the author, date, and commit message of all commits in reverse chronological order. The latest commit appears at the top of the list.

Here’s an example:

$ git log
commit b4691c6fd3feb96eed5b51c4f9ebdd5738cde0eb (HEAD -> main, origin/main, origin/HEAD)
Author: John Doe <[email protected]>
Date:   Fri Jul 23 15:51:47 2021 -0400

    Add new feature

commit 0e94d82558f8c8ed494e7714c7bc28c41462a9e1
Author: Jane Smith <[email protected]>
Date:   Thu Jul 22 11:24:35 2021 -0400

    Update documentation

commit 3028c5a76d78f6c673296b059b452fe466305d20
Author: John Doe <[email protected]>
Date:   Wed Jul 21 09:17:26 2021 -0400

    Fix bug in login feature

In this example, the git log command lists the three most recent commits in the repository, showing the commit hash, the author, the date, and the commit message for each one.

GIT BRANCH

git branch is a Git command used to list, create, or delete branches in a Git repository. When used with no arguments, it lists all existing branches in the repository.

Here’s an example of how git branch can be used:

$ git branch
* master
  development
  feature-123

In this example, the git branch command is used to list all the branches in the repository. The * character indicates the currently checked out branch, which is master in this case. The other branches listed are development and feature-123.

You can also use git branch with additional arguments to create or delete branches. For example, to create a new branch called new-feature, you can run:

$ git branch new-feature

And to delete a branch called old-feature, you can run:

$ git branch -D old-feature

I hope this helps! Let me know if you have any other questions.