Please enable JavaScript.
Coggle requires JavaScript to display documents.
GIT Level 2, git merge, after approval - Coggle Diagram
GIT Level 2
Commits
git commit --amend
Modify the last commit with additional changes or a new message
git log
show commit history
git commit -m "commit message"
Commit staged changes with the message
git reset <commit-hash>
Reset to a specific commit
git add .(dot)
Stage all files to commit
git revert <commit-hash>
Create a new commit that undoes a specific commit
git add <file>
Stage a specific file to commit
Remote Repositories
git remote add origin <repository-url>
points the current git repo to a remote repo
git pull
Fetch and merge changes from remote repo
git fetch
Fetch changes from remote repo without merging
git push origin <branch-name>
Push all the changes to the new branch under remote origin, no tracking, so just using git push, git pull won't work, always specify the branch name
git push -u origin <branch-name>
Push the changes to the new branch under remote origin and set the local git to keep track of the changes. Then, just using git push, git pull already points to that branch
git branch -vv
Lists out all branches and show
which remote branches are being tracked
git branch --unset-upstream <branch-name-optional>
This takes care of unsetting the upstream connection to the remote , no longer keeps track of changes when git push or git pull is used
Branch Mgmt
git checkout -b <branch-name>
create and switch to the new branch
git branch -d <branch-name>
Deletes the branch
git checkout <branch-name>
switch to another branch
git merge <branch-name>
Merge another branch into the current branch
git branch <branch-name>
create a new branch
git branch
List all branches
most common sequences done in project
git commit and push to latest Practice branch
git fetch origin - this fetches all the changes from remote to local
git merge <specific-branch> - this merges the latest changes from <specific-branch> to Practice branch
git reflog - this gives us entire history of changes done to the branch
use git reflog to identify the commits associated with certain changes.
git reset --hard <commit-hash> - this makes the current branch to go back to this commit which is easier than stashing, if the changes does not matter much.
Basic GIT Setup
git config --global user.name "user.name"
git config --global user.email
"user@example.com
"
associate user name or email to the repository
git clone <repository-url>
if you’re starting a project by pulling from an existing online repository, use git clone
git status
Current state of the working directory and show all staged changes
git init
Initialize a git repository
Tags for Releases
branch vs tag
Branch is typically a new line of dev work vs Tag is just a specific point or version in a code
Branch can have commits vs Tags are fixed snapshot
Branches are temporary(created, merged or deleted) vs Tags are permanent
Branches keep track of ongoing changes vs Tags don't track anything after it is created
git tag <tag-name>
create a lightweighted tag
git tag -a <tag-name> -m "tag message"
create tag with an annotated message for future reference
git push origin <tag-name>
Can also be called with
git push origin refs/tags/v1.0
Irrespective of all the commits created after the tag gets created, when you push a tag, then only the commits until the tag is created gets pushed to origin
git push origin --tags
Push all the tags and all the corresponding commits until the last tag of this branch
Merge Conflicts
git diff
Show differences between commits or working trees.
git merge <branch-name>
Merge the current branch with the given branch
git mergetool
use mergetool to start resolve the conflicts
git commit
commit all the resolved conflicts
Reverting Changes
git checkout -- <file>
Discard local changes in a file.
git reset HEAD <file>
Unstage a staged file
git reset --hard <commit-hash>
Discard all changes back to a specific commit
GIT WorkFlow for Test Automation
DEVELOPER BRANCH
New Project / Features
New Developer Branches
git push
Feature 1 Branch
git merge
git push
Feature 2 Branch
After Integration Testing
QA BRANCH
release: git merge, git tag
git push
MAIN/MASTER BRANCH
git push
CI/CD
pipeline
Automation Test Suite Execution after project developer's deployment
Stashing Changes
git merge
after approval