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
github [2022/03/01 19:31]
pwolinsk
github [2022/03/01 19:58] (current)
pwolinsk
Line 40: Line 40:
  
 **3.** add new files to the index (list) of files managed with git. (''git add <file_name>'',''git status'') **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 52:
 # file1 # file1
 # file2 # file2
-nothing added to commit but untracked files present (use "git add <file_name>" to track)+nothing added to commit but untracked files present (use "git add" 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 118: Line 119:
 pinnacle-l1:pwolinsk:~/project1$ cat file1 pinnacle-l1:pwolinsk:~/project1$ cat file1
 Some text in file1 Some text in file1
-line 2 
 pinnacle-l1:pwolinsk:~/project1$ cat file2 pinnacle-l1:pwolinsk:~/project1$ cat file2
 More text in file 2. More text in file 2.
 line 2 again line 2 again
-pinnacle-l1:pwolinsk:~/project1$ git reset --hard cd7ebfa2e6e67cf4e918be7bbba5c0e79af76036 +pinnacle-l1:pwolinsk:~/project1$ git checkout d4a8ab16fc53ba39b8bdf8f3b40db21681901f2f 
-HEAD is now at cd7ebfa added initial text to file 2+Note: checking out 'd4a8ab16fc53ba39b8bdf8f3b40db21681901f2f'
 + 
 +You are in 'detached HEAD' state. You can look around, make experimental 
 +changes and commit them, and you can discard any commits you make in this 
 +state without impacting any branches by performing another checkout. 
 + 
 +If you want to create a new branch to retain commits you create, you may 
 +do so (now or later) by using -b with the checkout command again. Example: 
 + 
 +  git checkout -b new_branch_name 
 + 
 +HEAD is now at d4a8ab1... added initial text to file 1
 pinnacle-l1:pwolinsk:~/project1$ cat file1 pinnacle-l1:pwolinsk:~/project1$ cat file1
 Some text in file1 Some text in file1
 +pinnacle-l1:pwolinsk:~/project1$ cat file2
 +pinnacle-l1:pwolinsk:~/project1$ 
 +</code>
 +
 +**8.** Go back to the latest version of files. (''git log --all'' shows all commits even those after the current commit version,''git checkout <commit_id>'')
 +
 +<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$ 
 +pinnacle-l1:pwolinsk:~/project1$ git checkout db1a5f1746b635bdbb73ebcc49dc3cf56a8ba2cf
 +Previous HEAD position was d4a8ab1... added initial text to file 1
 +HEAD is now at db1a5f1... added extra lines to file1 and file2
 +pinnacle-l1:pwolinsk:~/project1$ cat file1
 +Some text in file1
 +line 2
 pinnacle-l1:pwolinsk:~/project1$ cat file2 pinnacle-l1:pwolinsk:~/project1$ cat file2
 More text in file 2. More text in file 2.
 +line 2 again
 pinnacle-l1:pwolinsk:~/project1$  pinnacle-l1:pwolinsk:~/project1$ 
 </code> </code>
github.1646163102.txt.gz · Last modified: 2022/03/01 19:31 by pwolinsk