Difference between revisions of "Merging"
Line 168: | Line 168: | ||
=== Partner B in Emacs === | === Partner B in Emacs === | ||
'''Partner B''' can now receive the changes made by Partner A, but let's be smarter and use the features available from within emacs. | |||
Start emacs, opening "story.txt". |
Revision as of 18:11, 14 April 2019
Research[edit]
Introduction to Version Control (Emacs)
Experiment[edit]
Note: You will need to work with a partner for this lab. (We'll call the partners, Partner A and Partner B.)
First Steps[edit]
Only Partner A should perform the following steps:
Only Partner B should perform the following steps:
Both Partners[edit]
Both partners should now log on to the server.
Create a project directory:
cd ~/projects
mkdir project-1601
cd project-1601
Important: Do not skip this step! In order to successfully complete the remainder of the lab, it's important that your username and password (credentials) for GitHub are saved for future access. You can accomplish this by following the steps here and then continuing with this project.
Next, both partners should clone the newly created repository. Note that the actual name of the repository will depend on the user name of Partner A. Adjust the URL appropriately by replacing PARTNER_A_USER_NAME with the actual Partner A user name.
git clone https://github.com/PARTNER_A_USER_NAME/TheStory
Depending on your configuration, you may need to enter your username and password for GitHub. However, after this point, your credentials should be cached and you shouldn't need to enter them again and again.
Now, enter the directory and then pull the contents from the repository.
cd TheStory
git pull
Partner B on the Command Line[edit]
Partner B should now perform the following:
- Create a new file, "story.txt", with emacs:
emacs story.txt
Next, copy and paste the following text into the file. Then, save the file and exit.
Whilst we were talking, we heard a sort of sound between a yelp and a bark. It was far away; but the horses got very restless, and it took Johann all his time to quiet them. He was pale and said, "It sounds like a wolf - but yet there are no wolves here now." "No?" I said, questioning him. "Isn't it long since the wolves were so near the city?"
Check the status of your local git repository by typing:
git status
Question: After carefully reading the output text of the command, why do you think "story.txt" is listed as "untracked"?
In order to track the file, type:
git add story.txt
Helpful hint: If you need to add multiple files there's no need to issue the command multiple times. Just list the files one after another, separated by a space.
Check the status again:
git status
Question: After carefully reading the output text of the command, why do you think "story.txt" is listed as "new file"?
In order to commit your changes to your local repository, type:
git commit
Emacs will open enabling you to type a description of what you've changed (added, modified, deleted). This should be a useful message. For ideas about how to ensure that your message is useful, read The Art of the Commit (by David Demaree). After entering your message, save and exit emacs as usual.
Check the status again:
git status
Question: After carefully reading the output text of the command, what do you think is meant by "Your branch is ahead of 'origin/master' by 1 commit"?
Let's push the changes to the remote repository:
git push
Verify that your changes are visible on GitHub by going to the same URL that you used for the git clone
operation.
Partner A on the Command Line[edit]
Partner A can now receive the changes made by Partner B. To do so, Partner A should execute:
git pull
To check the directory contents, execute:
ls
Open the file in emacs:
emacs story.txt
Next, copy and paste the following text to the end of the file. Then, save the file and exit.
"Long, long," he answered, "in the spring and summer; but with the snow the wolves have been here not so long."
What changed from the previous commit? Have a look with:
git diff
Now, check the status:
git status
Question: After carefully reading the output text of the command, why do you think "story.txt" is shown in red as "modified"?
Now, use git to add, commit, and push your changes to your remote repository on GitHub.
Partner B in Emacs[edit]
Partner B can now receive the changes made by Partner A, but let's be smarter and use the features available from within emacs.
Start emacs, opening "story.txt".