Github 2
Github 2
GitHub:
GitHub is a free and open source version control system used for source code
management, tracking the changes in the source code. It allows to developers
to work together.
Features:
Build code: Developers can use GitHub to write a code, track changes.
Share work: we can showcase the and let others review it
Collaborate: Multiple people can work on a same project simultaneously
without worrying about conflicting work.
Git:
Git is command line interface toll used to interact or manage the remote
repositories from local
Git Branch:
Branches used for parallel development for two or group of people work on
same piece later we can integrate by merging.
git init initialize the git on local on first time
git branch <branch_name> used to create branch
git branch list the branches / can show current branch
git checkout <branch_name> used to switch between the branches
git branch -b <branch_name> create new branch and switch to same branch
Git clone:
Used to bring the remote repository to the local for the first time, or copying
the remote repo to local.
git clone <repo url>
Git add:
Adding the file to staging area. It moves the file from workspace to staging.
git add . or git add <file_name>
Git Commit:
Git commit will moves the files from staging area to git repository ( can give
message about the changes)
Git commit -m “message”
Git Push:
Used to push the changes from local repo to remote repo.
git push origin <source branch>:<destination branch>
Git pull:
used to bring the changes from remote repo to local repo and it will
automatically merges the changes to your current branch so we need careful
when pulling the code.
git pull <repo url>
Git fetch:
Used to pull the changes from remote repo to local repo and it won’t merge
the changes to your current branch you can create branch then you can merge
manually if required.
git fetch <repo url>
Git status:
This command is used to check whether the files in workspace or in staging
area.
Git log:
This command can be used to check the history of the repository.
Git Merge:
Git merge is used to merge the changes between branches or integrate the
changes from one branch to another branch.
It will create new commit for each merge.
Git rebase:
This is also used for merging the changes from one branch to anther
Git revert:
Git revert is used to undo the committed changes but it doesn’t delete the
history we can track easily who has done the revert because it creates new
commit id for each revert.
It will occur when same piece of code is changed in two different branches, so
when we try to merge the branches conflict will occur.
As a devops person I don’t know which changes should I merge. So I will
contact the developer who modified the code on the two branches using git
log. They will decide which changes need to keep in then file then we will start
merging.
Git cherry-pick:
Git squash:
Git stash:
So this will store it on temporary, once you complete that critical work on
another branch you can switch to main branch where you working, then you
can resume your work by running git stash pop command.
git stash
Branching strategy:
code is ready for 1st release, we create the branch release 1.0 from the
development branch and we make 1st release from the release 1.0
branch.
for the 2nd release, whatever the issue we got on release 1.0 , we fix it
Once the code is ready for 2nd release on the development branch,