In the last local repository statement, I learned about source code management such as commit, branch, log through Git’s basic commands.In this remote storage, let’s learn how to collaborate with others by linking what we worked locally to GitHub, and summarize how to resolve conflicts in the merge process.Create Remote Storage, log in to GitHub first, and then click the New button on the Repositories tab to create a new Repository.
Create Remote Repository

I set the Repository name to git_project just like the previous working folder, and set the rest to the default settings.Also, please set it to public!
remote repository

remote repository
태재 local repository 현상

Looking at the breakdown of the commits so far, I made three commits in the master branch and made another commit by creating a feature A branch in the last commit.Integrate this state with Remote Repository and upload previous commit history.Remote Storage Registration (remoteadd) First, register remote storage as follows.
git remote add
gitremoteaddorigin[repositoryaddress]This command was used to register the generated remote storage under the name origin. The name origin can be arbitrarily determined by the user.Change branch name (branch-M) Normally, you have to set up upstream to connect, but before that, change the branch name first.
Rename BranchI gave the -M option to gitbranch and changed the name of the master branch to the main branch.Upstream setting (upstream), when I push without setting the upstream first, I can’t find repository and get an error.They want us to set the upstream as shown in the picture below.Push before upstreamThen, I will set up the upstream as below and push it.Push to Remote Storage※ If the push is successful without errors here, please continue.If you receive a permission error, follow these steps!token issuancePress your own account and Settings-Developersettings Press your own account to go to Settings and go straight down to the bottom and you’ll find Developer Settings.developer configurationToken (Classic)Then go to Token(classic) on the Personal Access tokens tab and press Generate new token.token generationtoken generationAfter push is complete, repositoryAfter push is complete, repositoryCommand Description gitremote Output gitremote-v Remote Storage List Added to Current Branch Output gitremoteadd [Remote Storage Name] Register Remote Storage Address with Remote Storage Name gitremote-M [Branch Name] [Branch Name] [Branch Name to Change] Change Branch Name gitpush-u [Local Store Branch-File Set-Option Uploaded to Remote Storage Brand Name1. Start collaboration with push and pull. Now that it’s linked to remote storage, I have to collaborate with my colleagues!Download the contents of the storage with gitpush and gitpull, or upload what you have done locally.1.1gitpush, I uploaded the contents of the main(master) branch among the contents we worked on.If you look at the previous work, there is also the content of the feature A branch.So I will upload the contents of feature A through push.git pushGitogGitoggitclone from the Workspace2 folderThen, let’s go into the repository downloaded by cdgit_project/ and check the log.git pullAs you can see, the contents of developer A[WorkSpace/git_project] and developer B[WorkSpace2/git_project] are the same.There is nothing to pull in the current state, so I will commit and push again in the developer A work folder.Developer A made a bug and committed! In this way, I intentionally put a bug in developer A and committed and pushed it to remote storage.After that, if you take a log with developer A and developer B, it will appear as follows.The repository has changed. If developer A works like this and pushes the contents, developer B cannot know the changes until synchronization.So let’s download the contents of the changed remote storage using gitpull.Developer B did a git pull.After gitpulling with developer B like this, it became the same as what developer A worked on.※ The git pull has a git fetch that retrieves changes to remote storage and a git merge process that merges them. Let’s look at fetch and merge from behind.Command Description git clone [remote storage address] Download remote storage contents Git push Upload local branch files to remote storage Set up factor optional git pull [remote storage name] [local branch name] Download remote storage contents to local branch Set up factor optional2. Merge the commitments. This time, let’s take a look at the process of merging the functions developed by developer B in feature A into the main branch and uploading them.2.1 git merge From now on, use git merge [branches with merge capabilities] in the main branch to merge what you have done with existing feature A into main.ZimmelgeThis shows that the featrueA.py file, which was not found in the main branch, was merged into the main branch after working with the previous feature A.If you look at the log again, the local storage content is before the remote storage content.Now, let’s update the contents of push remote storage.However, it is better to delete the branch that is not used before that, so I will delete the developed feature A branch and push it.git pushgit pushbranch deletion metastasis, and bran : ch – [ a branch mei ] removed B developer, or we should push for the first time settings are upstream with the – u option because, please.and here also secured in Kiso ” Naga-konbu “, with the above method when an error occurs or expression that can not be one more time with a Tokenizer and in an address set in, please.2. 1 of the ‘ sketches ’ and the time swtch Manager : developers, the developer after development B muraji geki from the content of a Subversion repository must download, in association with each other, is completed.ago to google.com fetchmail Pull and swtch emerge at the same time progress, but This time around, while emerge fetchmail and the process will go.First, a developer terminal of the following progress in again, please.ZimmelgeIn gitmerge, the main branch of local storage is combined with the main branch of remote storage, and the contents of developer A and developer B are the same.However, I will not use feature A branch anymore, so I will delete it for you.branch deletionEnter gitpush –delete [branch name] to delete the remote storage branch as shown above.Command Description git merge [branch name] Merge the contents of the relevant branch to the branch you are currently working on. Download git fetch remote storage changes. git push origin-delete [branch name] Delete remote storage branch. git branch -d [branch name] Delete relevant branch3. Resolving consolidation conflicts, during these collaborations, communication errors or errors can be corrected by other developers.At this time, if merge proceeds, merge conflict occurs.Let’s look at how to resolve these merge conflicts.I will proceed again in the developer A folder.Developer A StatusI will make one branch in this developer A state.In the main branch, we will remove the bug that we made on app.py , and in the new branch, we will add another bug.Let’s take a look at the conflicts that occur when developers working in different branches modify the same location and merge.Correct the same lineCorrected the same line, corrected the same line like this, and proceeded to gitadd and commit in each branch.Then, let’s merge the contents of the bug branch with the main branch.a collision.This attempt to merge results in a conflict.And if you look at the code…a collision.Thus an obscure code is inserted.This is the new feature the same line is corrected through the want solved and a display by a worker, so I don’t know what is right.So I want to show you been prepared as follows.< < < = == == (1) HEAD (code code 2) > > > > a boolean The meaning of this is indicated by the HEAD is) and (b) is corrected to a branch, that is currently of a main branch (code ) the testing branch is corrected, a display that both branches are in the same in the (code ).Therefore, in order to solve this conflict he left a correct chord name was confirmed by a worker but shut them off. code.Collision resolution!I left the normal code like this and deleted the bug code.And if you look at the terminal againMerge is still in progress!MERGING is after the branch name after merging and colliding.This is because the code has been modified, but the merge has not been completely completed.Then add and commit the modified code again to complete the merge.Collision resolution complete!If you proceed to commit like this, the conflict resolution is complete!So far, we’ve seen how to upload and download code in collaboration with other developers through remote storage.We then looked at how to resolve conflicts that occur in the process of merging and merging completed features.This completes the basic Git/GitHub usage.Thank you for reading this long sentence.22.12.19 – Initial Creation#git #github #github #github #github #브허repos #remote #library #library #clone #clone #clone #github #github #github #message #message