Notice in the Git log that the most recent commit has identifier 6d8dafe72a198ed63d11be8592c39bcd14179a6b (NOTE: this identifier string may be different on your computer!). You can resolve this situation with the git revert command. Now suppose you dicide that the summary is not that useful and that you’d rather do the histogram like you had it before. The git log command gives you the commit identifier, the author of the commit, the date of the commit, and the short message that you provided with each commit. Once you are done editing the file, you can save/close it and run git diff to see a summary of the changes. You can load the file in our favorite editor and add the line summary(x) Suppose you want to change the code in your code.R file and print a summary of the data instead of plotting a histogram. It is possible to have other branches of development but we will skip that for now. The master branch is considered the main line of development. Notice that the first line says On branch master. Nothing to commit (working directory clean) It should say something like ~/myproject% git status ~/myproject% git commit -m "Initial code for plotting histogram"Ĭreated initial commit 7425153: Initial code for plotting histogramġ files changed, 2 insertions(+), 0 deletions(-)Īfter committing the change you can run git status. Make sure you write something informative (but concise) or else you won’t have any idea what you did when you look at it later. If you do not use this switch git will open an editor session for you to enter a message. The git commit command requires that you provide a short message about what the changes are and this can be done using the -m switch. Now that you have added your new code file you can commit the change using git commit. Now code.R is listed under Changes to be committed and is considered a new file. Running git status again after this command produces ~/myproject% git status This can be done using git add code.R: ~/myproject% git add code.R This is because you need to tell Git that you want to track the changes in this file. ![]() Notice that the code.R file is listed under Untracked files. Nothing added to commit but untracked files present (use "git add" to track) For example, let’s create a file named code.R containing some R code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |