User Tools

Site Tools


github

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
github [2022/03/01 18:46]
pwolinsk
github [2022/03/01 19:31]
pwolinsk
Line 17: Line 17:
 The following example shows step by step how to use git to keep track of changes made to your personal project on Pinnacle. The following example shows step by step how to use git to keep track of changes made to your personal project on Pinnacle.
  
-**1.** create a new project directory and initialize its management with git.+**1.** create a new project directory and initialize its management with git. (''git init'')
  
 <code> <code>
Line 39: Line 39:
 </code> </code>
  
-**3.** add new files to the index (list) of files managed with git+**3.** add new files to the index (list) of files managed with git. (''git add <file_name>'',''git status'')
 <code> <code>
 pinnacle-l1:pwolinsk:~/project1$ git status pinnacle-l1:pwolinsk:~/project1$ git status
Line 51: Line 51:
 # file1 # file1
 # file2 # file2
-nothing added to commit but untracked files present (use "git add" to track)+nothing added to commit but untracked files present (use "git add <file_name>" to track)
 pinnacle-l1:pwolinsk:~/project1$ git add file1 pinnacle-l1:pwolinsk:~/project1$ git add file1
 pinnacle-l1:pwolinsk:~/project1$ git add file2 pinnacle-l1:pwolinsk:~/project1$ git add file2
Line 68: Line 68:
 </code> </code>
  
-**4.** create a snapshot of the current state of all files tracked by git in the project directory+**4.** create a snapshot of the current state of all files tracked by git in the project directory. (''git commit -m "commit comment" <file_to_commit>'')
 <code> <code>
 pinnacle-l1:pwolinsk:~/project1$ git commit -m "added initial text to file 1" file1 pinnacle-l1:pwolinsk:~/project1$ git commit -m "added initial text to file 1" file1
Line 81: Line 81:
 </code> </code>
  
 +**5.** modify file1 and file2 and create another snapshot of the current version of files.  (''git commit -a -m "commit comment"'' will commit all tracked files in a project with a single comment.)
 +<code>
 +pinnacle-l1:pwolinsk:~/project1$ echo "line 2" >> file1
 +pinnacle-l1:pwolinsk:~/project1$ echo "line 2 again" >>file2
 +pinnacle-l1:pwolinsk:~/project1$ git commit -a -m "added extra lines to file1 and file2"
 +[master db1a5f1] added extra lines to file1 and file2
 + 2 files changed, 2 insertions(+)
 +pinnacle-l1:pwolinsk:~/project1$ 
 +</code>
 +
 +**6.** review a history of commits. (''git log'')
 +<code>
 +pinnacle-l1:pwolinsk:~/project1$ git log
 +commit db1a5f1746b635bdbb73ebcc49dc3cf56a8ba2cf
 +Author: pwolinsk <gh_email>
 +Date:   Tue Mar 1 12:47:48 2022 -0600
 +
 +    added extra lines to file1 and file2
 +
 +commit cd7ebfa2e6e67cf4e918be7bbba5c0e79af76036
 +Author: pwolinsk <gh_email>
 +Date:   Tue Mar 1 12:45:02 2022 -0600
 +
 +    added initial text to file 2
 +
 +commit d4a8ab16fc53ba39b8bdf8f3b40db21681901f2f
 +Author: pwolinsk <gh_email>
 +Date:   Tue Mar 1 12:44:55 2022 -0600
 +
 +    added initial text to file 1
 +pinnacle-l1:pwolinsk:~/project1$ 
 +</code>
 +
 +**7.** Revert to a previous version of the files.  (''git checkout <commit_id>'')
 +<code>
 +pinnacle-l1:pwolinsk:~/project1$ cat file1
 +Some text in file1
 +line 2
 +pinnacle-l1:pwolinsk:~/project1$ cat file2
 +More text in file 2.
 +line 2 again
 +pinnacle-l1:pwolinsk:~/project1$ git reset --hard cd7ebfa2e6e67cf4e918be7bbba5c0e79af76036
 +HEAD is now at cd7ebfa added initial text to file 2
 +pinnacle-l1:pwolinsk:~/project1$ cat file1
 +Some text in file1
 +pinnacle-l1:pwolinsk:~/project1$ cat file2
 +More text in file 2.
 +pinnacle-l1:pwolinsk:~/project1$ 
 +</code>
  
 ===== GitHub ===== ===== GitHub =====
github.txt ยท Last modified: 2022/03/01 19:58 by pwolinsk