Skip to content

Instantly share code, notes, and snippets.

@appikonda
Last active January 11, 2019 22:55
Show Gist options
  • Save appikonda/a4dafeaaa3435c40085a85e478fdde10 to your computer and use it in GitHub Desktop.
Save appikonda/a4dafeaaa3435c40085a85e478fdde10 to your computer and use it in GitHub Desktop.
All About GIT

Updating your current branch with dev-branch before pushing the code

git  pull origin branch-name

git stash -u  //if there are any working changes

git status

git checkout dev-branch 

git fetch origin

git pull origin dev-branch

git checkout - (shortcut: checkout previous branch) or git checkout branch-name 

git stash pop // if you did git stash earlier

git status

git merge dev-branch  // before commit

Creating bugfix branch from master and pushing the changes to dev branch

git checkout bugfix-branch

git  pull origin bugfix-branch

git stash -u  //if there are any working changes

git status

git checkout dev

git fetch origin

git pull origin master

git checkout - or git checkout branchname

git stash pop

git status

git merge dev // before commit

git add <file-name> or git add . 

git commit -m "commit-message"

Create PULL REQUEST

Update commit message after pushing code to dev-branch

git commit --amend -m "new commit meesage"

git push --force origin branch-name

// need force push for squash commits

Undo the last commit before pushing it

git reset --soft HEAD~1

Resolve Merge Conflicts after creating Pull Request to QA branch

git checkout feature/branch-name (Source Branch)

git pull origin feature/branch-name (up to date with remote branch)

git checkout qa-phase-5 (Destination Branch)

git pull origin qa-phase-5 (up to date with remote branch)

git merge feature/branch-name (merge feature branch into qa-phase-5)

git mergeTool (To resolve merge conflicts)

git add <file-name> (Stage the modified files)

git commit - m "JIRA-number: Resolve Merge Conflict Comments" (commit and add comments)

git checkout -b  mergeFix/feature/branch-name (creates a new branch to track the merge conflict changes - branched out from destiantion branch)

git push origin mergeFix/feature/branch-name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment