To use Git, developers use specific commands to copy, create, change, and combine code. These commands can be executed directly from the command line or by using an application like GitHub Desktop or Git Kraken.
Basic Operations
The following is a summary of basic git operations:
git add
Puts current working files into the stage.
git checkout
Replaces the current working files with files from a branch.
git checkout -b
Creates a new local branch from the current branch's tip.
git clone
Clone an existing repository into a new directory.
git commit
Commits staged changes to a local branch.
git commit -a
Commits all modified files to a local branch (shorthand for "git add" followed by
"git commit" for each modified file)
git fetch
Downloads changes from a remote repository into the local clone.
git merge
Merges files from a given branch into the current branch.
git pull
Fetches remote changes on the current branch into the local clone, and merges
them into the current working files.
git push
Uploads changes from all local branches to the respective remote repositories.
git reset
Makes the current branch point to some specific revision or branch
git rebase
Integrates changes from one branch into another. It is an alternative to the
better known "merge" command.
git fork
Fork will create a copy of the repository in your GitHub account so that you
can make changes to the project.
Video Reference: Basic Operation
Task
- Create a repository with name “Cognizance” on GitHub using Git Bash.
- Create a folder with name “Task-2” in the repository and upload the screenshot of Task-2.
- Create a folder with name “Task-3” in the repository and perform the Git operations using Git Bash.
- Take a screenshot of all the Git operations you performed and compile it in a single PDF and upload it in “Task-3” folder