Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. **PROBLEM:** Upload your source content to the remote origin for the first time.
  2.  
  3. **SOLUTION:** First create an empty repository to the remote origin. Then locally you should run the following git commands.
  4. ```
  5. $ cd 'go to your application path'
  6. $ git init
  7. $ git remote add origin 'put remote repository url'
  8. $ git add .
  9. $ git commit -m "write a comment"
  10. $ git push origin master
  11. ```
  12.  
  13. **PROBLEM:** How to merge branch with master?
  14.  
  15. **SOLUTION:**
  16. ```
  17. $ git checkout master
  18. $ git merge 'your development branch'
  19. $ git push origin master
  20. $ git checkout 'your development branch'
  21. ```
  22.  
  23. **PROBLEM:** Your branch and 'origin/master' have diverged.
  24.  
  25. **SOLUTION:** Run `git pull` to merge the remote branch into yours. As a result of that, if you have unmerged paths then you should fix conflicts first and then run `git commit -m "give a message here"`. Otherwise run `git merge --abort` to abort the merge.
  26.  
  27. **PROBLEM:** `$ git push origin master` shows the following error as follows:
  28. Updates were rejected because the remote contains work that you do
  29. not have locally. This is usually caused by another repository pushing
  30. to the same ref. You may want to first merge the remote changes (e.g.,
  31. `git pull`) before pushing again. See the 'Note about fast-forwards' in `git push --help` for details.
  32.  
  33. **SOLUTION:** `$ git pull` or `$ git push -f origin master`
  34.  
  35. BEWARE: Using `force` can change the history for other contributors on the same project. Basically, if you do not care about a file being deleted for everyone, just go ahead. Especially if you are the only contributor on the project.
  36.  
  37. However, `$ git pull` may generate the following issue:
  38. >"please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch."
  39.  
  40. We can get rid of this issue by executing the following steps:
  41. 1. press `i`
  42. 2. write your `merge` message
  43. 3. press `esc`
  44. 4. write `:wq`
  45. 5. then press `enter`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement