- Open Terminal.
- Change the current working directory to your local project.
- List your existing remotes in order to get the name of the remote you want to change.
$ git remote -v > origin https://github.com/USERNAME/REPOSITORY.git (fetch) > origin https://github.com/USERNAME/REPOSITORY.git (push) - Change your remote's URL from HTTPS to SSH with the git remote set-url command.
$ git remote set-url origin git@github.com:USERNAME/REPOSITORY.git - Verify that the remote URL has changed.
$ git remote -v # Verify new remote URL > origin git@github.com:USERNAME/REPOSITORY.git (fetch) > origin git@github.com:USERNAME/REPOSITORY.git (push)
Last active
November 16, 2023 03:53
-
-
Save arsho/0f11ce4b625a518522f0646423f99e8c to your computer and use it in GitHub Desktop.
Git workflow , git conflict , merging repository , git remote
git add --all
git commit -m "Issue:xxx message"
git push origin branch_name
git fetch origin
git checkout develop
git reset --hard origin/develop
git checkout -b branch_name
git checkout branch_name
git fetch origin
git rebase origin/develop
git push origin branch_name -f
git checkout FILE_PATH
git fetch origin
git checkout develop
git reset --hard origin/develop
git checkout branch_name
git rebase develop
git push origin branch_name -f
- Install Git:
sudo apt install git - Add global configuration for Git user:
git config --global user.email "you@example.com" git config --global user.name "Your Name" - Add SSH. Details can be found in this gist
git status -s is listing all files as modified even after resetting hard git reset --hard origin/main.
To resolve this:
git config core.filemode false
git reset --hard origin/main
git status
# Output: On branch develop
git stash
git checkout -b feature/NEW-142
git stash pop
git add .
git commit -m "NEW-152: added env variables"
git push origin feature/NEW-142
The error occurred when trying to push code to the same branch. It was showing:
Updates were rejected because the tip of your current branch is behind
Rebase the current branch with the dev(Change it to your own main branch) branch.
git add --all
git commit -m "feature-555: commit message"
git push origin feature-555
(Error occurred in this step)
git fetch origin
git rebase origin/dev
git push origin feature-555 -f
A repository is forked from another repository. Now the forked repository is needed to rebase with original repository.
- Add the original repository as
upstream:git remote add upstream https://example.com/[Original Owner Username]/[Original Repository].git - List currently configured remote repositories:
It will show thegit remote -voriginandupstream:origin https://example.com/[Your UserName]/[Your Fork].git (fetch) origin https://example.com/[Your UserName]/[Your Fork].git (push) upstream https://example.com/[Original Owner UserName]/[Original Repository].git (fetch) upstream https://example.com/[Original Owner UserName]/[Original Repository].git (push) - Fetch contents from
upstream:git fetch upstream - Checkout to an existing branch (e.g.
master):git checkout master - Rebase this branch with
upstream's branch:git rebase upstream/master - Push changes to forked repository:
git push origin master
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment