Thursday, September 15, 2022

You have divergent branches and need to specify out of three options (merge, rebase, fast-forward) how to reconcile them. What to do?

You have divergent branches and need to specify out of three options (merge, rebase, fast-forward) how to reconcile them. What to do?

Let's experiment and figure out what these three reconciling strategies do.

Clone a Server Copy

(base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/server/repo_for_testing$ git pull Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': Already up to date. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/server/repo_for_testing$ git log commit b20128a7b6148aa7ed668cfe2531a54418e61097 (HEAD -> main, origin/main, origin/HEAD) Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:21:37 2022 +0530 20220915

Clone Three Local Copies

Local Copy 1

(base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1$ git clone https://github.com/ashishjain1547/repo_for_testing.git Cloning into 'repo_for_testing'... Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': remote: Enumerating objects: 39, done. remote: Counting objects: 100% (39/39), done. remote: Compressing objects: 100% (24/24), done. remote: Total 39 (delta 13), reused 23 (delta 4), pack-reused 0 Receiving objects: 100% (39/39), 8.45 KiB | 4.23 MiB/s, done. Resolving deltas: 100% (13/13), done.

Local Copy 2

(base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2$ git clone https://github.com/ashishjain1547/repo_for_testing.git Cloning into 'repo_for_testing'... Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': remote: Enumerating objects: 39, done. remote: Counting objects: 100% (39/39), done. remote: Compressing objects: 100% (24/24), done. remote: Total 39 (delta 13), reused 23 (delta 4), pack-reused 0 Receiving objects: 100% (39/39), 8.45 KiB | 2.82 MiB/s, done. Resolving deltas: 100% (13/13), done.

Local Copy 3

(base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3$ git clone https://github.com/ashishjain1547/repo_for_testing.git Cloning into 'repo_for_testing'... Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': remote: Enumerating objects: 39, done. remote: Counting objects: 100% (39/39), done. remote: Compressing objects: 100% (24/24), done. remote: Total 39 (delta 13), reused 23 (delta 4), pack-reused 0 Receiving objects: 100% (39/39), 8.45 KiB | 2.82 MiB/s, done. Resolving deltas: 100% (13/13), done. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3$

Update the Server Copy

(base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/server/repo_for_testing$ echo " " > 20220915_2336.html (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/server/repo_for_testing$ git add -A (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/server/repo_for_testing$ git commit -m "20220915 II" [main 80b40f5] 20220915 II 1 file changed, 1 insertion(+) create mode 100644 20220915_2336.html (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/server/repo_for_testing$ git push Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Delta compression using up to 4 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 248 bytes | 248.00 KiB/s, done. Total 2 (delta 1), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (1/1), completed with 1 local object. To https://github.com/ashishjain1547/repo_for_testing.git b20128a..80b40f5 main -> main

Run Git Push Command on Local Copies Without Doing a Git Pull First.

Local Copy 1

(base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1$ cd repo_for_testing/ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ echo " " > 20220915_2340.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git add -A (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git commit -m "20220915 Update on local copy 1" [main a01092f] 20220915 Update on local copy 1 1 file changed, 1 insertion(+) create mode 100644 20220915_2340.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git push Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': To https://github.com/ashishjain1547/repo_for_testing.git ! [rejected] main -> main (fetch first) error: failed to push some refs to 'https://github.com/ashishjain1547/repo_for_testing.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git status On branch main Your branch is ahead of 'origin/main' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git pull Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Compressing objects: 100% (1/1), done. remote: Total 2 (delta 1), reused 2 (delta 1), pack-reused 0 Unpacking objects: 100% (2/2), 228 bytes | 228.00 KiB/s, done. From https://github.com/ashishjain1547/repo_for_testing b20128a..80b40f5 main -> origin/main hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation. fatal: Need to specify how to reconcile divergent branches. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git status On branch main Your branch and 'origin/main' have diverged, and have 1 and 1 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git log commit a01092fe6048d236bb71b1ea95d80e6084a340aa (HEAD -> main) Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:41:11 2022 +0530 20220915 Update on local copy 1 commit b20128a7b6148aa7ed668cfe2531a54418e61097 Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:21:37 2022 +0530 20220915 (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git pull Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation. fatal: Need to specify how to reconcile divergent branches. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git config pull.rebase false (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git pull Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': Merge made by the 'ort' strategy. 20220915_2336.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 20220915_2336.html (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ ls -l total 64 -rw-rw-r-- 1 ashish ashish 29 Sep 15 23:31 20210528_test_branch.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:31 202107141543.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:31 202107141608.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:31 202107211228.txt -rw-rw-r-- 1 ashish ashish 12 Sep 15 23:31 202110111920.txt -rw-rw-r-- 1 ashish ashish 2 Sep 15 23:47 20220915_2336.html -rw-rw-r-- 1 ashish ashish 2 Sep 15 23:40 20220915_2340.txt -rw-rw-r-- 1 ashish ashish 2 Sep 15 23:31 20220915.txt -rw-rw-r-- 1 ashish ashish 7 Sep 15 23:31 Archana.txt -rw-rw-r-- 1 ashish ashish 45 Sep 15 23:31 Ashish -rw-rw-r-- 1 ashish ashish 11357 Sep 15 23:31 LICENSE -rw-rw-r-- 1 ashish ashish 10 Sep 15 23:31 newFile.txt -rw-rw-r-- 1 ashish ashish 36 Sep 15 23:31 README.md -rw-rw-r-- 1 ashish ashish 22 Sep 15 23:31 test_file_20210528.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git log commit a24385b836c5e877571693b5e15a5a44512c1053 (HEAD -> main) Merge: a01092f 80b40f5 Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:47:47 2022 +0530 Merge branch 'main' of https://github.com/ashishjain1547/repo_for_testing commit a01092fe6048d236bb71b1ea95d80e6084a340aa Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:41:11 2022 +0530 20220915 Update on local copy 1 commit 80b40f50dcfebbcc39766c30ae5cb5b253f6d0ba (origin/main, origin/HEAD) Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:37:45 2022 +0530 20220915 II

Local copy is ahead of server by two commits.

(base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git status On branch main Your branch is ahead of 'origin/main' by 2 commits. (use "git push" to publish your local commits) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git push Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': Enumerating objects: 6, done. Counting objects: 100% (6/6), done. Delta compression using up to 4 threads Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 529 bytes | 529.00 KiB/s, done. Total 4 (delta 2), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (2/2), completed with 1 local object. To https://github.com/ashishjain1547/repo_for_testing.git 80b40f5..a24385b main -> main (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 1/repo_for_testing$ git status On branch main Your branch is up to date with 'origin/main'. nothing to commit, working tree clean

Local Copy 2

$ git config pull.rebase true # rebase

(base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2$ cd repo_for_testing/ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ ls -l total 56 -rw-rw-r-- 1 ashish ashish 29 Sep 15 23:33 20210528_test_branch.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:33 202107141543.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:33 202107141608.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:33 202107211228.txt -rw-rw-r-- 1 ashish ashish 12 Sep 15 23:33 202110111920.txt -rw-rw-r-- 1 ashish ashish 2 Sep 15 23:33 20220915.txt -rw-rw-r-- 1 ashish ashish 7 Sep 15 23:33 Archana.txt -rw-rw-r-- 1 ashish ashish 45 Sep 15 23:33 Ashish -rw-rw-r-- 1 ashish ashish 11357 Sep 15 23:33 LICENSE -rw-rw-r-- 1 ashish ashish 10 Sep 15 23:33 newFile.txt -rw-rw-r-- 1 ashish ashish 36 Sep 15 23:33 README.md -rw-rw-r-- 1 ashish ashish 22 Sep 15 23:33 test_file_20210528.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git status On branch main Your branch is up to date with 'origin/main'. nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ echo "local copy 2" > 20220915_local_copy_2.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git add -A (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git commit -m "local copy 2" [main 824f879] local copy 2 1 file changed, 1 insertion(+) create mode 100644 20220915_local_copy_2.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git push Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': To https://github.com/ashishjain1547/repo_for_testing.git ! [rejected] main -> main (fetch first) error: failed to push some refs to 'https://github.com/ashishjain1547/repo_for_testing.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git status On branch main Your branch is ahead of 'origin/main' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git pull Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': remote: Enumerating objects: 7, done. remote: Counting objects: 100% (7/7), done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 4), reused 4 (delta 2), pack-reused 0 Unpacking objects: 100% (6/6), 623 bytes | 311.00 KiB/s, done. From https://github.com/ashishjain1547/repo_for_testing b20128a..a24385b main -> origin/main hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation. fatal: Need to specify how to reconcile divergent branches. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git status On branch main Your branch and 'origin/main' have diverged, and have 1 and 3 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git config pull.rebase true (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git pull Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': Successfully rebased and updated refs/heads/main. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ ls -l total 68 -rw-rw-r-- 1 ashish ashish 29 Sep 15 23:33 20210528_test_branch.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:33 202107141543.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:33 202107141608.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:33 202107211228.txt -rw-rw-r-- 1 ashish ashish 12 Sep 15 23:33 202110111920.txt -rw-rw-r-- 1 ashish ashish 2 Sep 16 00:00 20220915_2336.html -rw-rw-r-- 1 ashish ashish 2 Sep 16 00:00 20220915_2340.txt -rw-rw-r-- 1 ashish ashish 13 Sep 16 00:00 20220915_local_copy_2.txt -rw-rw-r-- 1 ashish ashish 2 Sep 15 23:33 20220915.txt -rw-rw-r-- 1 ashish ashish 7 Sep 15 23:33 Archana.txt -rw-rw-r-- 1 ashish ashish 45 Sep 15 23:33 Ashish -rw-rw-r-- 1 ashish ashish 11357 Sep 15 23:33 LICENSE -rw-rw-r-- 1 ashish ashish 10 Sep 15 23:33 newFile.txt -rw-rw-r-- 1 ashish ashish 36 Sep 15 23:33 README.md -rw-rw-r-- 1 ashish ashish 22 Sep 15 23:33 test_file_20210528.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git status On branch main Your branch is ahead of 'origin/main' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git log commit 858945ca963a48977eea5682e6dc54eb1f87eba1 (HEAD -> main) Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:58:20 2022 +0530 local copy 2 commit a24385b836c5e877571693b5e15a5a44512c1053 (origin/main, origin/HEAD) Merge: a01092f 80b40f5 Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:47:47 2022 +0530 Merge branch 'main' of https://github.com/ashishjain1547/repo_for_testing commit a01092fe6048d236bb71b1ea95d80e6084a340aa Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:41:11 2022 +0530 20220915 Update on local copy 1 commit 80b40f50dcfebbcc39766c30ae5cb5b253f6d0ba Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:37:45 2022 +0530 20220915 II commit b20128a7b6148aa7ed668cfe2531a54418e61097 Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:21:37 2022 +0530 20220915 (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git status On branch main Your branch is ahead of 'origin/main' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git push Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 4 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 305 bytes | 305.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (1/1), completed with 1 local object. To https://github.com/ashishjain1547/repo_for_testing.git a24385b..858945c main -> main (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$ git status On branch main Your branch is up to date with 'origin/main'. nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 2/repo_for_testing$

Local Copy 3

$ git config pull.ff only # fast-forward only

(base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3$ cd repo_for_testing/ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git status On branch main Your branch is up to date with 'origin/main'. nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ ls -l total 56 -rw-rw-r-- 1 ashish ashish 29 Sep 15 23:34 20210528_test_branch.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:34 202107141543.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:34 202107141608.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:34 202107211228.txt -rw-rw-r-- 1 ashish ashish 12 Sep 15 23:34 202110111920.txt -rw-rw-r-- 1 ashish ashish 2 Sep 15 23:34 20220915.txt -rw-rw-r-- 1 ashish ashish 7 Sep 15 23:34 Archana.txt -rw-rw-r-- 1 ashish ashish 45 Sep 15 23:34 Ashish -rw-rw-r-- 1 ashish ashish 11357 Sep 15 23:34 LICENSE -rw-rw-r-- 1 ashish ashish 10 Sep 15 23:34 newFile.txt -rw-rw-r-- 1 ashish ashish 36 Sep 15 23:34 README.md -rw-rw-r-- 1 ashish ashish 22 Sep 15 23:34 test_file_20210528.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ echo "local copy 3" > 20220915_local_copy_3.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git add -A (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git commit -m "#" [main 5c8d1ff] # 1 file changed, 1 insertion(+) create mode 100644 20220915_local_copy_3.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git push Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': To https://github.com/ashishjain1547/repo_for_testing.git ! [rejected] main -> main (fetch first) error: failed to push some refs to 'https://github.com/ashishjain1547/repo_for_testing.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git status On branch main Your branch is ahead of 'origin/main' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git pull Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': remote: Enumerating objects: 10, done. remote: Counting objects: 100% (10/10), done. remote: Compressing objects: 100% (6/6), done. remote: Total 9 (delta 5), reused 6 (delta 2), pack-reused 0 Unpacking objects: 100% (9/9), 875 bytes | 437.00 KiB/s, done. From https://github.com/ashishjain1547/repo_for_testing b20128a..858945c main -> origin/main hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation. fatal: Need to specify how to reconcile divergent branches. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git status On branch main Your branch and 'origin/main' have diverged, and have 1 and 4 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git config pull.ff only (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ ls -l total 60 -rw-rw-r-- 1 ashish ashish 29 Sep 15 23:34 20210528_test_branch.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:34 202107141543.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:34 202107141608.txt -rw-rw-r-- 1 ashish ashish 16 Sep 15 23:34 202107211228.txt -rw-rw-r-- 1 ashish ashish 12 Sep 15 23:34 202110111920.txt -rw-rw-r-- 1 ashish ashish 13 Sep 16 00:14 20220915_local_copy_3.txt -rw-rw-r-- 1 ashish ashish 2 Sep 15 23:34 20220915.txt -rw-rw-r-- 1 ashish ashish 7 Sep 15 23:34 Archana.txt -rw-rw-r-- 1 ashish ashish 45 Sep 15 23:34 Ashish -rw-rw-r-- 1 ashish ashish 11357 Sep 15 23:34 LICENSE -rw-rw-r-- 1 ashish ashish 10 Sep 15 23:34 newFile.txt -rw-rw-r-- 1 ashish ashish 36 Sep 15 23:34 README.md -rw-rw-r-- 1 ashish ashish 22 Sep 15 23:34 test_file_20210528.txt (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git status On branch main Your branch and 'origin/main' have diverged, and have 1 and 4 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git log commit 5c8d1ff9d1e3d40daabf2b7cbcdc9f9b4e9003b3 (HEAD -> main) Author: Ashish Jain <ashishjain1547@gmail.com> Date: Fri Sep 16 00:14:43 2022 +0530 # commit b20128a7b6148aa7ed668cfe2531a54418e61097 Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:21:37 2022 +0530 20220915 commit 335cb1656a8b862733936531d0e00da92cea7f8f (origin/test_branch) Author: Ashish Jain <ashishjain1547@gmail.com> Date: Mon Oct 11 19:39:46 2021 +0530 Create Ashish commit 99da43ac015c1ed065796b4681ce2fdfd34d426c Author: unknown <ashishjain1547@gmail.com> Date: Mon Oct 11 19:37:33 2021 +0530 We will push this code with new file named Archana. commit be275fd83426869e3d8a27f8346ab903d6343faa Author: unknown <ashishjain1547@gmail.com> Date: Mon Oct 11 19:20:28 2021 +0530 20211011 1920 commit 9f1b42fe6b2cf1fbc3781cdb463b284f871ad291 Merge: d210505 087a5ca Author: unknown <ashishjain1547@gmail.com> Date: Wed Jul 21 12:41:37 2021 +0530 Merge branch 'test_branch' into main commit 087a5ca85b88f7303d025e8770183a6eabbeca7a Author: unknown <ashishjain1547@gmail.com> Date: Wed Jul 21 12:29:09 2021 +0530 20210721 1229 commit d2105058469fdb461a61578f8672e769d4426d79 Merge: daa4600 9017804 Author: Ashish Jain <ashishjain1547@gmail.com> Date: Wed Jul 14 16:25:29 2021 +0530 Merge pull request #1 from ashishjain1547/test_branch Test branch commit 901780465a07e7ce78932226db29a0898a07f4a2 Author: unknown <ashishjain1547@gmail.com> (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git pull Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication failed for 'https://github.com/ashishjain1547/repo_for_testing.git/' (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git pull Username for 'https://github.com': ashishjain1547@gmail.com Password for 'https://ashishjain1547@gmail.com@github.com': fatal: Not possible to fast-forward, aborting. (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git status On branch main Your branch and 'origin/main' have diverged, and have 1 and 4 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working tree clean (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ git log commit 5c8d1ff9d1e3d40daabf2b7cbcdc9f9b4e9003b3 (HEAD -> main) Author: Ashish Jain <ashishjain1547@gmail.com> Date: Fri Sep 16 00:14:43 2022 +0530 # commit b20128a7b6148aa7ed668cfe2531a54418e61097 Author: Ashish Jain <ashishjain1547@gmail.com> Date: Thu Sep 15 23:21:37 2022 +0530 20220915 commit 335cb1656a8b862733936531d0e00da92cea7f8f (origin/test_branch) Author: Ashish Jain <ashishjain1547@gmail.com> Date: Mon Oct 11 19:39:46 2021 +0530 Create Ashish commit 99da43ac015c1ed065796b4681ce2fdfd34d426c Author: unknown <ashishjain1547@gmail.com> Date: Mon Oct 11 19:37:33 2021 +0530 We will push this code with new file named Archana. commit be275fd83426869e3d8a27f8346ab903d6343faa Author: unknown <ashishjain1547@gmail.com> Date: Mon Oct 11 19:20:28 2021 +0530 20211011 1920 commit 9f1b42fe6b2cf1fbc3781cdb463b284f871ad291 Merge: d210505 087a5ca Author: unknown <ashishjain1547@gmail.com> Date: Wed Jul 21 12:41:37 2021 +0530 Merge branch 'test_branch' into main commit 087a5ca85b88f7303d025e8770183a6eabbeca7a Author: unknown <ashishjain1547@gmail.com> Date: Wed Jul 21 12:29:09 2021 +0530 20210721 1229 commit d2105058469fdb461a61578f8672e769d4426d79 Merge: daa4600 9017804 Author: Ashish Jain <ashishjain1547@gmail.com> Date: Wed Jul 14 16:25:29 2021 +0530 Merge pull request #1 from ashishjain1547/test_branch Test branch commit 901780465a07e7ce78932226db29a0898a07f4a2 Author: unknown <ashishjain1547@gmail.com> (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$ (base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop/git_practical/local 3/repo_for_testing$
Tags: Technology,GitHub,

No comments:

Post a Comment