Necessary Git Commands

Necessary Git Commands


Fix: Permission denied (publickey)

git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Check Current Remote

git remote -v

Set Correct Remote Destination

git remote set-url origin git@rdbb.bitbucket.org:darmist/WebLogicWeb.git

Amend the Last Commit (Keep Same Commit Message)

git add .
git commit --amend --no-edit
git push --force

Amend the Last Commit (Change Commit Message)

git add .
git commit --amend -m "Updated commit message"
git push --force

Download All Codes from a Branch

Pull from Master

git pull origin master

Pull from Another Branch

git pull origin ranadepto

Push Updated Code

git add .
git status
git commit -m "Updated code with new features"
git push origin ranadepto

Copy Code to a New Branch

git checkout -b ranadepto
git add .
git status
git commit -m "Copying codes to the new ranadepto branch"
git push origin ranadepto

Merge Branches from Command Line

git checkout master
git merge ranadepto

Reset for Merge Conflict and Pull Fresh Code

Reset and Pull Master

git fetch --all
git reset --hard origin/main
git pull origin main

Reset and Pull Another Branch

git fetch --all
git reset --hard origin/shakat
git pull origin shakat
0%