Can you explain me how to use git in case, when I have access to repository:
I tried these steps
git init
git clone git.repository
git pull develop (where develop is branch)
git add .
git commit -m "m"
git push origin develop
Result is:
* branch develop -> FETCH_HEAD
fatal: refusing to merge unrelated histories
What I do wrong?
Push a new Git branch to a remote repo Clone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.
In case you are using the Tower Git client, pushing to a remote is very easy: simply drag your current HEAD branch in the sidebar and drop it onto the desired remote branch - or click the "Push" button in the toolbar.
Push Branch to Another Branch In some cases, you may want to push your changes to another branch on the remote repository. In order to push your branch to another remote branch, use the “git push” command and specify the remote name, the name of your local branch as the name of the remote branch.
Suppose you have created a new branch on GitHub with the name feature-branch.
FETCH
git pull --all Pull all remote branches
git branch -a List all branches now
Checkout and switch to the feature-branch directory. You can simply copy the branch name from the output of branch -a command above
git checkout -b feature-branch
VALIDATE
Next use the git branch command to see the current branch. It will show feature-branch with * In front of it
git branch check current branch
git status check the state of your codebase
COMMIT
git add . add all untracked files
git commit -m "Rafactore code or use your message"
Take update and the push changes on the origin server
git pull origin feature-branch
git push origin feature-branch
OR you can rebase with the master before commit
git fetch
git rebase origin/master
git push origin feature-branch
How to download repository
# download a repository
git clone <url>
How to push changes in selected branch
# push changes to remote branch
# assuming you are on the master branch right now
git push origin master
How to select branch to push
# push any desired branch to remote
git push -u origin local_branch_name:remote_branch_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With