Wednesday, 5 February 2020

github sync local and remote repo

cd [project_directory]

change remote branch
git checkout [branch_name]

PS C:\Users\chuanshuo\native-base> git checkout
M       App.js
M       CommodityListItem.js
M       Drawer.js
M       assets/icomoon.ttf
M       assets/selection.json
Your branch is up to date with 'origin/master'.

change remote origin
git remote -v
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

PS C:\Users\chuanshuo\native-base> git remote -v
origin  https://github.com/chuanshuoge6/nativebase-commodity-price.git (fetch)
origin  https://github.com/chuanshuoge6/nativebase-commodity-price.git (push)

push local to remote
git push

remove last commit
git reset --hard HEAD~1

C:\Users\bob\native-base>git log
commit 7a23c64c86cd95217e6d9c6f0d1da04da4207ea3 (HEAD -> master)
Author: unknown <zchen2019@zoho.com>
Date:   Wed Feb 5 18:34:49 2020 -0700

    pull1

commit da4d5545d8b89bab2d50a440cd0c572eee183784
Merge: 252f747 fa3a69a
Author: unknown <zchen2019@zoho.com>
Date:   Wed Feb 5 18:34:00 2020 -0700

    pull1

commit fa3a69a67d2e8eba07e4ab9fafadfc2ceff14d86 (origin/master)
Author: chuanshuoge <zchen2019@zoho.com>
Date:   Wed Feb 5 16:15:52 2020 -0700

    '8th'

commit b5d62be51d3ba1c1731c4de83309bbc9907b67c8
Author: chuanshuoge <zchen2019@zoho.com>
Date:   Wed Feb 5 11:28:45 2020 -0700

    '7th'

commit 252f747d5281d6dd35dbc08102c3ff2a877b1f16
Author: unknown <zchen2019@zoho.com>
Date:   Wed Feb 5 08:21:47 2020 -0700

No next tag  (press RETURN) press q to quit                                                                                         

...skipping...
commit 7a23c64c86cd95217e6d9c6f0d1da04da4207ea3 (HEAD -> master)
Author: unknown <zchen2019@zoho.com>
Date:   Wed Feb 5 18:34:49 2020 -0700

    pull1

commit da4d5545d8b89bab2d50a440cd0c572eee183784
Merge: 252f747 fa3a69a
Author: unknown <zchen2019@zoho.com>
Date:   Wed Feb 5 18:34:00 2020 -0700

    pull1

commit fa3a69a67d2e8eba07e4ab9fafadfc2ceff14d86 (origin/master)
Author: chuanshuoge <zchen2019@zoho.com>
Date:   Wed Feb 5 16:15:52 2020 -0700

    '8th'

commit b5d62be51d3ba1c1731c4de83309bbc9907b67c8
Author: chuanshuoge <zchen2019@zoho.com>
Date:   Wed Feb 5 11:28:45 2020 -0700

    '7th'

commit 252f747d5281d6dd35dbc08102c3ff2a877b1f16
Author: unknown <zchen2019@zoho.com>
Date:   Wed Feb 5 08:21:47 2020 -0700

    '7th'
                                                                                                                     
C:\Users\bob\native-base>git reset --hard HEAD~1
HEAD is now at da4d554 pull1

C:\Users\bob\native-base>git reset --hard HEAD~1
HEAD is now at 252f747 '7th'

pull remote repo, compare with local
git pull origin

C:\Users\bob\native-base>git pull origin
Auto-merging ForexListItem.js
CONFLICT (add/add): Merge conflict in ForexListItem.js
Auto-merging App.js
CONFLICT (content): Merge conflict in App.js
Automatic merge failed; fix conflicts and then commit the result.

C:\Users\bob\native-base>git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 2 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Changes to be committed:

        modified:   package.json

Unmerged paths:
  (use "git add <file>..." to mark resolution)

        both modified:   App.js

solve conflict in text editor, accept incoming, current, both

git add .
git commit -m 'merge1'
warning: LF will be replaced by CRLF in .expo-shared/assets.json.
...

git add .
git commit -m 'merge2'
On branch master
Your branch is up to date with 'origin/master'.

compare local to remote
C:\Users\bob\native-base>git diff master origin/master

C:\Users\bob\native-base>git fetch
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 4 (delta 3), reused 4 (delta 3), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/chuanshuoge6/nativebase-commodity-price
   e1f2e9c..83f29fe  master     -> origin/master

C:\Users\bob\native-base>git diff master origin/master
diff --git a/App.js b/App.js
index 4d5d6ae..e76904a 100644
--- a/App.js
+++ b/App.js
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
 import JSSoup from 'jssoup'
 import axios from 'axios'
 import * as Font from 'expo-font'
-import { Image } from 'react-native';
+import { Modal, TextInput } from 'react-native';
 import { TextInputMask } from 'react-native-masked-text'
 import { Col, Row, Grid } from "react-native-easy-grid";
 import DrawerContent from './Drawer'
@@ -64,6 +64,7 @@ export default class App extends Component {
       cad: null,
       eur: null,
       jpy: null,
+      btc: null,
       aud: null,
       gbp: null,
       nzd: null,
@@ -88,6 +89,8 @@ export default class App extends Component {
       ils: null,
       mxn: null,
       zar: null,
+      show_modal: false,
+      input_amount: 1000,
     };
   }

@@ -152,7 +155,7 @@ export default class App extends Component {
         })
           .then(response => {
             const soup = new JSSoup(response.data)
-            const rate = soup.find('p', 'quote-price').string.toString()
+            const rate = soup.find('p', 'quote-price').nextElement.toString()

reference:
https://www.koskila.net/how-to-git-merge-upstream/
https://stackoverflow.com/questions/1338728/delete-commits-from-a-branch-in-git
https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-using-the-command-line
https://help.github.com/en/desktop/contributing-to-projects/syncing-your-branch
https://stackoverflow.com/questions/1800783/how-to-compare-a-local-git-branch-with-its-remote-branch

No comments:

Post a Comment