Git: Git is a version control system
Terminologies Meaning
Project A project is base on multiple tasks of a research or target for achieve a particular aim.
Repositories Where Project data placed or stored.
Clone a copy of project for local working.
It’s a standard convention for remote repository where a project was originally placed
Origin
or stored and project also cloned from here for local work.
On cloning a project to a local system its repository has a single local branch that is
Master
called Master branch. We can also say it default branch.
A branch represents an independent line of development. Branch just like a brand-
Branch
new working directory, staging area, and project history
Staging branch status during working /modifying on it and it ready to commit.
Committing On committing branch work or changes finalized and added in to our local code.
Merge After completing work on a single task or multiple tasks combine them with main project.
Pull Get the latest version of the project/branch to a local copy for working.
Push updates the main project with local changes / modifications.
Commands Functionality
Initialized the local directory for git. this is usually the first command we'll run in a
new project or convert a directory to Git repository. Its creates a .git subdirectory in
git init
the current working directory, which contains all of the necessary Git metadata for
the new repository.
By using this we up to date our local repository from remote repository. It is
git pull
combination of two commands (fetch + merge)
updates all the remote tracking branches in local repository. No changes are actually
git fetch
reflected on any of the local working branches.
git merge It will merge the corresponding remote tracking branch to the local working branch.
git branch <branch-name>
For creating a new branch
git branch For checking the current working branch.
Show the list of all branches. * and green color of name show currently working
git branch -a
branch.
git checkout <branch-name> Change/switch a branch for working we use checkout command
It shows the state of git repository.
Files present in Git repository in two states.
git status Tracked - files that Git knows about and are added to the repository
Untracked - files that are in our working directory, but not added to the repository
it adds our work/changes in stage state where we can review it for commit or revert.
git add <filename>
For a single file we can use its name with command and if our work consists of two or
or
more files then we can use comma splitter file names or (–all) flag for all files with
git add –all
command.
This command saves our work in staging environment and in simply commit is our
git commit -m "message" save point where we can go back when needed. It also adds in the history of our
repository.
git log To view the commits history of a repository
git merge <branch-name> It merges the branch completed work with our local repository.
git branch -d <branch-name> It used for deleting a branch
git push <remote> <branch> Combine local working/changes on remote repository
Git CLI base functionality with Snap shots
➢ Creating new subtask ticket.
➢ Create new branch
➢ Pull from origin
➢ fetch from origin
➢ Check current branch
➢ Switch to required working branch by checkout and then check current branch
➢ Before adding folder in working branch its status, its working tree is clean.
➢ At bitbucket Origin master repository status
➢ Adding new folder with files in utilities
➢ Repository status after adding folder and it present as untracked files
➢ Add new folder with files to stage state by using git add command
➢ Repository status after git add command and it ready for committing.
➢ Now use git commit command we saving the changes/modification to our local repository and check
repository status again its tree clean
➢ Now we push our changes to remote repository by using git push command
➢ At bitbucket Origin master repository status