-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Fixing AddABWrapper
Why are there so many problems in this repo? Because we modified a file without
committing it. Git is excellent when you use it correctly. Git was designed to
supersede the bad practice of naive file versioning like copying the file
and adding the date to the end of the name. This is all over the place in these
repos and it is the source of all of our problems.
I'm seeing files like add-ab_flags20181214 and do-ab_20181214.tcsh and many
others. We're changing files without commit the changes and this causes errors.
I am going to correct all of these problems, and I am going to verbosely explain
each step I did and why I did it.
Please! Either read this document in its entirity or do not mess with the
repository and bring us back to this mess.
If you want to make a change but do not want to save it, just run
git reset --hard HEAD in the repository you're in to bring it back to its
original state. This is the only acceptable way to make file changes in the
Tyto repository if you do not intend to learn these git fundamentals.
Table of contents
- Solution
- Explanation
- git status
- git diff
- git fetch
- git merge
- Closing thoughts
Solution
I do not have write permission to /Users/CatWISE. To fix the merge issues, run
$ git fetch
$ git checkout -b master_01_09_2019
$ git add addABWrapper.tcsh do-ab_NOgsa.tcsh do-ab_gsa.tcsh
$ git commit -m "Temporarily saved files"
$ git checkout master
$ git checkout -- add-ab_flags do-ab.tcsh
$ git merge
Explanation
I can provide an explanation of what all of this means. I absolutely recommend
reading through it. I copied the entire CatWISE directory in my home folder. I
recommend you do the same.
cp -R /Users/CatWISE/AddABflags/AddABWrapper/ /Users/nrgarcia/CatWISE
so I could make any necessary changes. I'll outline the changes I did where and
why so that you can do the same things on /Users/CatWISE.
git status
I wanted to look into AddABWrapper since that seems to be getting a lot of
changes recently. So a quick cd AddABflags/AddABWrapper/ to get there. What I
care about is the git state. I run git status, which shows the status of the
current working tree. Specifically, it shows me what files have been changed
since the last commit of the current branch (we refer to the latest commit of
the current branch as HEAD). You can run git status --help for more info on
the command. Any git command I give, there is a --help option to document
what it does.
Step 1: Run git status to see the current state of the repository.
$ git status
On branch 2018_12_11
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
modified: addABWrapper.tcsh
deleted: do-ab.tcsh
typechange: gsa
Untracked files:
(use "git add <file>..." to include in what will be committed)
add-ab_flags20181214
add-ab_flags20181214.f
add-ab_flags2018oct04
addABWrapper2018dec14.tcsh
addABWrapper2018dec26.tcsh
addABWrapper2018oct04.tcsh
do-ab_20181214.tcsh
do-ab_20181214b.tcsh
do-ab_2018nov12.tcsh
do-ab_2018nov15.tcsh
do-ab_2018oct04.tcsh
do-ab_NOgsa.tcsh
do-ab_NOgsa2018dec26.tcsh
do-ab_gsa.tcsh
do-ab_gsa2018dec26.tcsh
gsa2018dec14
gsa2018oct04
no changes added to commit (use "git add" and/or "git commit -a")
Let's break down each section, in order.
Current branch
On branch 2018_12_11
As the text implies, this is telling us what branch we are currently on.
What is a branch?
A branch is just a reference to a specific commit. A commit is a complete
snapshot of your project directory at a specific state. A commit tells you what
every file looked like at that time. Commits track the history of your project
over time.
A brief introduction to commits
When you make changes to your project, you save those changes to git via a
commit. Git will save every commit you've made. That is, every change you've
ever made -as long as its committed- will be saved.
A commit will save more than just the file state. It also saves when it was made
(date and time), by who (author name and email), and a message about the commit
(the commit message). Git will also save the sha1 hashcode of all of this
information (changed files, author, date and time, and commit message).
Commits are often referenced by their sha1 hashcodes since they uniquely define
any commit. The commit that branch 2018_12_11 references is
d51caefe9736e21e8a28b3f5d13d9f10975d9e62. You can also reference a commit by
just the first few digits of its hash code. For example d51caef is a valid
way to reference the above commit.
A commit will also reference the commit(s) that came before it. So you can do
git log to get a full history of that commit from its current state to when
it was first created.
Step 1.1a: Run git log to see the history of your current branch.
$ git log
commit d51caefe9736e21e8a28b3f5d13d9f10975d9e62 (HEAD -> 2018_12_11)
Author: Peter Eisenhardt <Peter.R.Eisenhardt@jpl.nasa.gov>
Date: Tue Dec 11 16:27:03 2018 -0800
Update addABWrapper.tcsh
- replaced AddABWrapper with addABWrapper in grep search that limits number
of simultaneous jobs to 12
commit f43f71a4e182566b11a3d7a694df62929bb5aead (master)
Author: Elijah Marchese <emarc004@ucr.edu>
Date: Thu Oct 4 15:30:47 2018 -0700
Update do-ab.tcsh
commit c671e982c97ff9b012d00f96e79cd240468350d9
Author: acertainelijah <emarc004@ucr.edu>
Date: Thu Oct 4 15:18:46 2018 -0700
changed directory calls for addABWrapper.tcsh, gsa, & add-ab_flags
commit c1fbad44753f69ee1ee6c26212e84712435c436c
Author: acertainelijah <emarc004@ucr.edu>
:
Look at the first line
commit d51caefe9736e21e8a28b3f5d13d9f10975d9e62 (HEAD -> 2018_12_11)
It tells us what commit we're on: d51caef. It then shows us
(HEAD -> 2018_12_11). Recall that HEAD is just the latest commit of the
current branch, and 2018_12_11 is the branch we are currently on, so this is
consistent.
You will see the commit that came before it is f43f71a and that the branch
master points to this commit. In this state, we say that "branch 2018_12_11
is one commit ahead of branch master".
Step 1.1b: Run git log --oneline to get a more abbrievated history.
$ git log --oneline
d51caef (HEAD -> 2018_12_11) Update addABWrapper.tcsh
f43f71a (master) Update do-ab.tcsh
c671e98 changed directory calls for addABWrapper.tcsh, gsa, & add-ab_flags
c1fbad4 Updated rsync step and added new files
200ea9b Update README.md
53d87fe Update README.md
ed4101e Update README.md
4f1b677 Added Command line Parameters
00c6c57 Minor Changes
67f9fbe Update README.md
a546f0e minor echo debug edits
5c286ef Adding wrapper
9cffc6c Update README.md
8a19486 Update README.md
c96097d Initial commit
This format uses the short-length git hash code, and only shows the first line
of each commit message.
Changes not staged for commit
Let's look at the next section of the git status example.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
modified: addABWrapper.tcsh
deleted: do-ab.tcsh
typechange: gsa
The section is lisitng the files -that git is keeping track of- that have been
changed since the last commit. When I say "that git is keeping track of", I mean
that these files already exist somewhere in the git history.
The word "staged" is another git term. Changes to a file can be unstaged,
staged, or committed.
If the changes are "committed", then that means those changes have been saved to
the git history in the last commit object.
If the changes are "staged", that means when you run git commit, those staged
changes will be saved to a new commit object that is created as a result of
calling git commit.
If the files are unstaged, then those changes will not be saved to the commit.
Right now, no changes are staged. So if you run git commit, nothing will
happen.
$ git commit
no changes added to commit
Staging changes for commit
The next line of our git status example tells you how to add a file to the
staging area. You use git add/rm <file>. If you want to add changes of a file
to the staging area, you do git add <file>.
$ git add addABWrapper.tcsh
warning: LF will be replaced by CRLF in addABWrapper.tcsh.
The file will have its original line endings in your working directory
$ git status
On branch 2018_12_11
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: addABWrapper.tcsh
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
deleted: do-ab.tcsh
typechange: gsa
:
If you get warning: LF will be replaced by CRLF in <file>, there is no need to
worry, that's just to normalize newline characters in the sourecode files.
When we run git status, we see a new section:
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: addABWrapper.tcsh
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
deleted: do-ab.tcsh
typechange: gsa
:
Now, the changes to addABWrapper.tcsh are "staged". So if we did git commit,
these changes would be committed. But we'll not do that for now.
Unstaging changes for commit
You can do git reset HEAD <file> to unstage that file.
$ git reset HEAD addABWrapper.tcsh
Unstaged changes after reset:
D add-ab_flags
M addABWrapper.tcsh
D do-ab.tcsh
T gsa
This output is just the short-hand version of git status. You can invoke it
by calling git status -s but I won't go into its details.
Staging deleted files for commit
To stage a deleted file to be committed, you do git rm <file>.
$ $ git rm do-ab.tcsh
rm 'do-ab.tcsh'
Note that git rm <file> will also run rm file to actually remove the file if
it hasn't been yet.
We now see that the file is removed.
$ git status
On branch 2018_12_11
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: do-ab.tcsh
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
modified: addABWrapper.tcsh
typechange: gsa
:
Unstaging deleted files for commit
Again, you can do git reset HEAD <file> to unstage this change. Note that this
will not undelete the file.
$ git reset HEAD do-ab.tcsh
Unstaged changes after reset:
D add-ab_flags
M addABWrapper.tcsh
D do-ab.tcsh
T gsa
$ git status
On branch 2018_12_11
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
modified: addABWrapper.tcsh
deleted: do-ab.tcsh
typechange: gsa
:
Removing unstaged files
If a file is changed or deleted and it is unstaged, then you can call
git checkout -- <file> to discard those changes. This will also undelete any
files that you have deleted.
$ git checkout -- do-ab.tcsh
$ git status
On branch 2018_12_11
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
modified: addABWrapper.tcsh
typechange: gsa
:
$ ls
README.md do-ab_2018nov12.tcsh
add-ab_flags20181214 do-ab_2018nov15.tcsh
add-ab_flags20181214.f do-ab_2018oct04.tcsh
add-ab_flags2018oct04 do-ab_NOgsa.tcsh
addABWrapper.tcsh do-ab_NOgsa2018dec26.tcsh
addABWrapper2018dec14.tcsh do-ab_gsa.tcsh
addABWrapper2018dec26.tcsh do-ab_gsa2018dec26.tcsh
addABWrapper2018oct04.tcsh gsa
do-ab.tcsh gsa2018dec14
do-ab_20181214.tcsh gsa2018oct04
do-ab_20181214b.tcsh
We see that do-ab.tcsh is no longer deleted. You can delete it again to bring
the working directory back to its original state.
$ rm do-ab.tcsh
$ git status
On branch 2018_12_11
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
modified: addABWrapper.tcsh
deleted: do-ab.tcsh
typechange: gsa
:
Note that if a change is staged for a commit, you can't undo those changes with
git checkout -- <file>. That only works for unstaged changes.
$ git rm do-ab.tcsh
rm 'do-ab.tcsh'
$ git checkout -- do-ab.tcsh
error: pathspec 'do-ab.tcsh' did not match any file(s) known to git
$ git reset HEAD do-ab.tcsh
Unstaged changes after reset:
D add-ab_flags
M addABWrapper.tcsh
D do-ab.tcsh
T gsa
$ git checkout -- do-ab.tcsh
$ git status
On branch 2018_12_11
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
modified: addABWrapper.tcsh
typechange: gsa
:
You can also automatically delete and stage a file with git rm <file>.
$ git rm do-ab.tcsh
rm 'do-ab.tcsh'
$ git status
On branch 2018_12_11
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: do-ab.tcsh
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
modified: addABWrapper.tcsh
typechange: gsa
If you unstage this change, the file is still deleted though.
$ git reset HEAD do-ab.tcsh
Unstaged changes after reset:
D add-ab_flags
M addABWrapper.tcsh
D do-ab.tcsh
T gsa
Modified, deleted, and typechanges
deleted: add-ab_flags
modified: addABWrapper.tcsh
deleted: do-ab.tcsh
typechange: gsa
These descriptors should be fairly self-explanatory. The state how the file has
changed, and which file experienced the change.
A "typechange" usually only occurs with symlinks. This should only exist in my
local copy /Users/nrgarcia/CatWISE/AddABflags/AddABWrapper. You shouldn't see
it in /Users/CatWISE/AddABflags/AddABWrapper. It just means the symlink path
changed.
Untracked files
we now move on to the final section of git status.
Untracked files:
(use "git add <file>..." to include in what will be committed)
add-ab_flags20181214
add-ab_flags20181214.f
add-ab_flags2018oct04
addABWrapper2018dec14.tcsh
addABWrapper2018dec26.tcsh
addABWrapper2018oct04.tcsh
do-ab_20181214.tcsh
do-ab_20181214b.tcsh
do-ab_2018nov12.tcsh
do-ab_2018nov15.tcsh
do-ab_2018oct04.tcsh
do-ab_NOgsa.tcsh
do-ab_NOgsa2018dec26.tcsh
do-ab_gsa.tcsh
do-ab_gsa2018dec26.tcsh
gsa2018dec14
gsa2018oct04
no changes added to commit (use "git add" and/or "git commit -a")
These are new files according to git. Files of these names don't exist in the
git commit history. So there are no changes among them that can be tracked. If
you have untracked files in your git repository, you can still successfully pull
and merge remote changes, since there is no risk of file conflicts.
You can add these files to the staging area using git add <file> and unstage
them with `git reset HEAD .
Closing thoughts on git status
This was a lot of material to cover just to explain git status, but it also
covers how to stage and unstage file changes, which is also extremely important
for writing commits.
The last line of git status also shows you a quick and helpful way to skip
staging and just commit all files. You can do git commit -a. But beware that
this will save every file change. So only do it if that was intentional.
git diff
So what has git status shown me? I see that add-ab_flags and do-ab.tcsh have
been deleted. I also see that addABWrapper.tcsh was modified. Now I want to
know what these changes are.
Step 2: Run git diff addABWrapper.tcsh.
$ git diff addABWrapper.tcsh
warning: LF will be replaced by CRLF in addABWrapper.tcsh.
The file will have its original line endings in your working directory
diff --git a/addABWrapper.tcsh b/addABWrapper.tcsh
index bda5d16..f8e9ee7 100755
--- a/addABWrapper.tcsh
+++ b/addABWrapper.tcsh
@@ -6,7 +6,7 @@ echo
echo Wrapper Started at:
echo $startTime
echo
-echo Version 1.4
+echo Version 1.71 Fixed Output paths
echo
echo This Wrapper will wrap around and run:
echo 1\) do-add-ab_flags
@@ -18,12 +18,23 @@ echo 1\) do-add-ab_flags
#check hyphenated argument
@ i = 0
set rsyncSet = "false"
+set gsaSet = "false"
+set withinMode2 = "false" # Used to determine if mode 3 is being called within mode 2
while ($i < $# + 1)
:
Again, let's break this down section by section (this won't take as long as
git status).
warning: LF will be replaced by CRLF in addABWrapper.tcsh.
The file will have its original line endings in your working directory
This is a just a notice about newline character encodings. Not something we need
to be concerned about.
diff --git a/addABWrapper.tcsh b/addABWrapper.tcsh
index bda5d16..f8e9ee7 100755
These are just technical output that the CatWISE team shouldn't get too
concerned about. The first line is helpful to know which file you are currently
looking at.
@@ -6,7 +6,7 @@ echo
echo Wrapper Started at:
echo $startTime
echo
-echo Version 1.4
+echo Version 1.71 Fixed Output paths
echo
echo This Wrapper will wrap around and run:
echo 1\) do-add-ab_flags
This is a "chunk" of diff output. The "@@" specifies a new chunk. It's followed
by "-6,7". The "-" sign stands for the original file, "6" is the starting line
number, and "7" is the number number of lines in this chunk. Similarly, "+"
specifies the new file, and "6,7" specify the starting line is 6 and the chunk
is 7 lines long.
This line is optionally followed by another "@@" and some text, which describes
a section heading for this diff chunk. This section heading is usually the line
just before the starting line, or it can be the function this chunk is in (in
specific circumstances where git diff is clever enough to find such a
heading).
This format is called Unified diff format
If you were to read the contents of addABWrapper.tcsh, you'll see that
line 6 is "echo Wrapper Started at:". The line just before it is "echo" and
this is what git diff has decided will be this chunk's section header.
What follows are three context lines:
echo Wrapper Started at:
echo $startTime
echo
These three lines are unchanged in both versions of addABWrapper.tcsh. They
are only shown in the diff chunk for context.
Next we see the actual changes
-echo Version 1.4
+echo Version 1.71 Fixed Output paths
The "-" sign shows us the line of the original file, and the "+" shows the line
after the changes. So we see that "echo Version 1.4" was removed and
"echo Version 1.71 Fixed Output paths" was added.
If we did git add addABWrapper.tcsh followed by git commit, this change
would be present in the commit that is created (along with all of the other
changes in addABWrapper.tcsh).
What follows is the next diff chunk:
@@ -18,12 +18,23 @@ echo 1\) do-add-ab_flags
#check hyphenated argument
@ i = 0
set rsyncSet = "false"
+set gsaSet = "false"
set rsyncSet = "false"
+set gsaSet = "false"
+set withinMode2 = "false" # Used to determine if mode 3 is being called within mode 2
while ($i < $# + 1)
#user input nameslist -nl argument
if("$argv[$i]" == "-rsync") then
echo Argument "-rsync" detected. Will rsync Tyto, Otus, and Athene.
set rsyncSet = "true"
endif
+ if("$argv[$i]" == "-gsa") then
+ echo Argument "-gsa" detected. Will call gsa in do-ab_gsa.tcsh
+ set gsaSet = "true"
+ endif
+ if("$argv[$i]" == "-withinMode2") then
+ echo Argument "-withinMode2" detected.
+ set withinMode2 = "true"
+ echo $withinMode2
+ endif
@ i += 1
end
We're looking at 12 lines of the original file, starting at line 18, and
comparing them to 23 lines of the modified file, also starting atr line 18. The
section header is "echo 1) do-add-ab_flags".
When we look at the chunk contents, we see only addititions (only "+", no "-").
So nothing was removed. Content was only added.
You can also use git diff without specifying a file to see all of the tracked,
unstaged changes you've made so far to every file. You can also do
git diff --staged or git diff --cached to see how the changes that you have
staged for commit are different from the original files.
git fetch
The original problem we are running into is that we cannot do git pull. Git
keeps spitting out an error. To resolve this, I'll break down git pull. This
command, in reality, is just git fetch && git merge. We look at git fetch
here.
What git fetch does is download all of the commits and branches from a
different repository. A "repository" is just a folder where git data is saved.
If I were to run git fetch right now, the repository it would read from is
https://github.com/catwise/AddABWrapper.git, which, of course, is located on
GitHub. The repository I am working on right now is
/Users/nrgarcia/CatWISE/AddABflags/AddABWrapper/.git. The repository I am
trying to fix is /Users/CatWISE/AddABflags/AddABWrapper/.git.
When one repository references another repository, that other repository is
called a "remote" or "remote repository". You can figure out what remote
repositories your repository has by calling git remote -v.
$ git remote -v
origin https://github.com/catwise/AddABWrapper.git (fetch)
origin https://github.com/catwise/AddABWrapper.git (push)
So I have a remote named origin. If I run git fetch, it reads from
https://github.com/catwise/AddABWrapper.git. If I run git push, it writes to
https://github.com/catwise/AddABWrapper.git. Note that the fetch and push
destinations are usually the same. They don't have to be, but for our cases,
they should always be the same.
Remote repositories are not reversible. Just because my repository
/Users/nrgarcia/CatWISE/AddABflags/AddABWrapper/.git and your repository
/Users/CatWISE/AddABflags/AddABWrapper/.git both have a remote repository
named origin pointing to Github's repository at
https://github.com/catwise/AddABWrapper.git, that does not mean origin has a
remote repository pointing back to our repositories.
Before we run git fetch, let's see take a quick look at our history
Example 2: Run git log --oneline origin/master
$ git log --oneline origin/master
fb6c00a (origin/master, origin/HEAD) @PeterEisenhardt
144420e @PeterEisenhardt
ab97305 Adding opt0/opt1 distinction to temp output
56f4d37 @PeterEisenhardt
96cbcb8 Update README.md
861cdf4 @PeterEisenhardt
0f00bb3 Update addABWrapper.tcsh
f43f71a (master) Update do-ab.tcsh
c671e98 changed directory calls for addABWrapper.tcsh, gsa, & add-ab_flags
c1fbad4 Updated rsync step and added new files
200ea9b Update README.md
53d87fe Update README.md
ed4101e Update README.md
4f1b677 Added Command line Parameters
00c6c57 Minor Changes
67f9fbe Update README.md
a546f0e minor echo debug edits
5c286ef Adding wrapper
9cffc6c Update README.md
8a19486 Update README.md
c96097d Initial commit
What this command does is look at the history of the remote tracking branch
origin/master. This branch is called a "remote-tracking branch". It's not a
branch we work with directly. It is just a mirror of what the master branch of
origin looked like the last time we called git fetch.
The last commit we fetched from origin was fb6c00a. Let's see what happend
now that we run git fetch.
Step 3: Run git fetch.
$ git fetch
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 32 (delta 8), reused 8 (delta 5), pack-reused 16
Unpacking objects: 100% (32/32), done.
From https://github.com/catwise/AddABWrapper
fb6c00a..2529db8 master -> origin/master
Most of this output isn't important to us. All we care about is
From https://github.com/catwise/AddABWrapper
which tells the origin of the contents we're downloading, and
fb6c00a..2529db8 master -> origin/master
which tells us the range of commits (starting at commit fb6c00a, which was the
old most recent commit of origin/master, and ending at 2529db8 which is the
new most recent commit) from origin that we have downloaded since the last
time we fetched origin.
The commits came from the GitHub's branch master. We're saving them to our
own branch, origin/master.
If we ran git fetch again, there would be no new commits to download now.
$ git fetch
$
Let's get a better look at our changes.
Example 3: Run git log --oneline master^..origin/master
$ git log --oneline master^..origin/master
2529db8 (origin/master, origin/HEAD) @PeterEisenhardt
63d180e @PeterEisenhardt
7441259 Fixed Output Path
9629bdf Version 1.7 up to date!
8c9a6b2 Merge branch 'master' of https://github.com/catwise/AddABWrapper
abc6178 1\) use $5 in input list + input file 2\) added \-gsa 3\) make sure mdex and _af file path is different 4\) added rsync \(but not tested yet\!\!\!\)
72c8046 @PeterEisenhardt
0270f9e Merge branch 'master' of https://github.com/catwise/AddABWrapper
613feb2 added inputs $8 \(-n-m files path\) and $9\(temp2 files path\) to do-ab.tcsh
7f9b5c7 @PeterEisenhardt
fb6c00a @PeterEisenhardt
144420e @PeterEisenhardt
ab97305 Adding opt0/opt1 distinction to temp output
56f4d37 @PeterEisenhardt
96cbcb8 Update README.md
861cdf4 @PeterEisenhardt
0f00bb3 Update addABWrapper.tcsh
f43f71a (master) Update do-ab.tcsh
What master^..origin/master specifies is the range of commits we want to look
at. A range of commits X..Y means we start on the commit after X and read up
to the commit Y.
The ^ symbol means we reference the commit that came before the commit it is
attached to. So master^ means we are looking at the commit that came before
master, and master^..origin/master means we are looking at all commits
between master and origin/master.
We see that 2529db8 is the most recent commit of origin/master, just like
the output of git fecth told us.
git merge
This is the command that is giving us issues right now. Let's see what happens.
Example 4: Run git merge
$ git merge
fatal: No remote for the current branch.
This is telling us that the current branch we are on, 2018_12_11 does not
have a remote branch. We can see our current branch and other branches with
git branch.
$ git branch
* 2018_12_11
master
The asterisk tells us which branch we are currently on. This is consistent with
the output of git status. The other branch we have access to is master, which
we will get to in a moment. To see the remote tracking branches also, we run
git branch -a.
$ git branch -a
* 2018_12_11
master
remotes/origin/HEAD -> origin/master
remotes/origin/master
The remote tracking branches we have are origin/HEAD (which points to
origin/master), which specifies the default branch that is put into a new
repository created with git clone. This isn't something we'll get into right
now.
The other remote branch is origin/master. We see no origin/2018_12_11,
which is why we are getting the "No remote for the current branch." error.
We want to work on the master branch anyway. This is our main branch. To
switch to a different branch, do git checkout <branch_name>.
Example 4: Run git checkout master.
$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
addABWrapper.tcsh
Please commit your changes or stash them before you switch branches.
Aborting
Argh another error! Why is this happening? Again, because we have all of these
changes that aren't committed. As the error states, we've made changes to the
file addABWrapper.tcsh. If we switched to branch master, these changes
would be lost. Git won't allow that. You can either commit your changes or stash
them.
Let's solve this in the git way, and compare it to the bad way it's been
done so far.
bad way:
- Copy
addABWrapper.tcshto a file of the same name with the date attached to
the end:addABWrapper01092018.tcsh. - Undo all of the changes to
addABWrapper.tcshso we can checkout the branch.
Note that, to undo these changes, we still have to use git. Then we have to use
git again to switch brnches and bring in changes. This is why I'm calling this
the bad way, because it's trying to resist using git as much as possible,
but the only solution still requires git.
git way:
- I'm guessing we want to save these files "just in case". That's why there are
so many files with date suffixes in their name. Rather than copying the file
and adding the date to the end, let's copy the branch and add the date to
it.
Step 4: Run git checkout -b master_01_09_2019
$ git checkout -b master_01_09_2019
D add-ab_flags
M addABWrapper.tcsh
D do-ab.tcsh
T gsa
Switched to a new branch 'master_01_09_2019'
git checkout -b <branch_name> is similar to git checkout <branch> in that
it switches us to a new branch, <branch_name>. The difference is the parameter
-b which specifies that <branch_name> is a brand new branch. This new branch
is an exact copy of the branch we were currently on before, 2018_12_11.
Notice that git checkout master gave us an error but git checkout -b ... did
not. The former gives an error because branch master has file changes to a
file that we have modified, addABWrapper.tcsh. Our new branch introduces no
changes to the working directory, so it is a safe operation.
Let's commit our problem file.
Step 5: Run git add addABWrapper.tcsh
$ git add addABWrapper.tcsh
warning: LF will be replaced by CRLF in addABWrapper.tcsh.
The file will have its original line endings in your working directory
$ git status
On branch master_01_09_2019
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: addABWrapper.tcsh
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: add-ab_flags
deleted: do-ab.tcsh
typechange: gsa
:
We can now commit this change.
Step 6: Run git commit -m "Temporarily saved file"
$ git commit -m "Temporarily saved file"
[master_01_09_2019 4b12dbc] Temporarily saved file
1 file changed, 153 insertions(+), 99 deletions(-)
The section [master_01_09_2019 4b12dbc] tells us the branch we committed to,
master_01_09_2019, and the commit object we created, 4b12dbc. It then shows
us the title of the commit message, Temporarily saved file, which we were able
to specify with the -m parameter of git commit.
The next line, 1 file changed, 153 insertions(+), 99 deletions(-), tells us
how many files were just (just addABWrapper.tcsh), how many lines were added,
and how many were deleted.
Now that we got rid of the problem file that was preventing
git checkout master from executing, we can try again.
Step 7: Run git checkout master (again).
$ git checkout master
D add-ab_flags
D do-ab.tcsh
T gsa
Switched to branch 'master'
Your branch is behind 'origin/master' by 17 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
The section
D add-ab_flags
D do-ab.tcsh
T gsa
just tells us what unstaged changes still exist in the new branch. There are no
changes in master that affect these files, so it is now safe to do this
switch. We can verify success by the message Switched to branch 'master'.
The next line,
Your branch is behind 'origin/master' by 17 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
tells us how far behind we are from the remote repository. These 17 commits are
the changes we are trying to add to the repo.
Example 5: Run git log --oneline master^..origin/master
$ git log --oneline master^..origin/master
2529db8 (origin/master, origin/HEAD) @PeterEisenhardt
63d180e @PeterEisenhardt
7441259 Fixed Output Path
9629bdf Version 1.7 up to date!
8c9a6b2 Merge branch 'master' of https://github.com/catwise/AddABWrapper
abc6178 1\) use $5 in input list + input file 2\) added \-gsa 3\) make sure mdex and _af file path is different 4\) added rsync \(but not tested yet\!\!\!\)
72c8046 @PeterEisenhardt
0270f9e Merge branch 'master' of https://github.com/catwise/AddABWrapper
613feb2 added inputs $8 \(-n-m files path\) and $9\(temp2 files path\) to do-ab.tcsh
7f9b5c7 @PeterEisenhardt
fb6c00a @PeterEisenhardt
144420e @PeterEisenhardt
ab97305 Adding opt0/opt1 distinction to temp output
56f4d37 @PeterEisenhardt
96cbcb8 Update README.md
861cdf4 @PeterEisenhardt
0f00bb3 Update addABWrapper.tcsh
f43f71a (HEAD -> master) Update do-ab.tcsh
You see that there are 17 commits that come after master.
Can we merge these changes now? Let's find out.
Example 6: Run git merge.
$ git merge
Updating f43f71a..2529db8
error: The following untracked working tree files would be overwritten by merge:
do-ab_NOgsa.tcsh
do-ab_gsa.tcsh
Please move or remove them before you merge.
Aborting
No. We cannot. Why? There are unsaved changes, still. We need to either remove
or merge these changes. We deleted add-ab_flags and do-ab.tcsh. I won't
commit these changes since I believe these files were moved to
add-ab_flags20181214 and do-ab_20181214.tcsh. The latter seems to have also
been copied to do-ab_20181214b.tcsh and several other variants. All of these
variants would be better executed in separate branches, which I will get into
later.
For now, let's return the deleted files.
Step 8: Run git checkout -- add-ab_flags do-ab.tcsh
$ git checkout -- add-ab_flags do-ab.tcsh
$ git status
On branch master
Your branch is behind 'origin/master' by 17 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
typechange: gsa
:
We see now the only unstaged change is typechange: gsa. Again, I think this
only takes place in my local repository since it is a symlink, so it probably
won't be visible in /Users/CatWISE.
Can we finally do git merge?
Example 7: Run git merge
$ git merge
Updating f43f71a..2529db8
error: The following untracked working tree files would be overwritten by merge:
do-ab_NOgsa.tcsh
do-ab_gsa.tcsh
Please move or remove them before you merge.
Aborting
Alas, no. Again we have conflicting changes. Our merge has files
do-ab_NOgsa.tcsh and do-ab_gsa.tcsh which would overwrite our files of the
same name that we've created on Tyto. So let's go back to master_01_09_2019
and save these changes there.
Step 9: Run git checkout master_01_09_2019,
git add do-ab_NOgsa.tcsh do-ab_gsa.tcsh, git commit -m "Save unstaged", and
git checkout master.
$ git checkout master_01_09_2019
T gsa
Switched to branch 'master_01_09_2019'
$ git add do-ab_NOgsa.tcsh do-ab_gsa.tcsh
warning: LF will be replaced by CRLF in do-ab_NOgsa.tcsh.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in do-ab_gsa.tcsh.
The file will have its original line endings in your working directory
$ git commit -m "Save unstaged"
[master_01_09_2019 f932964] Save unstaged
2 files changed, 56 insertions(+)
create mode 100755 do-ab_NOgsa.tcsh
create mode 100755 do-ab_gsa.tcsh
$ git checkout master
T gsa
Switched to branch 'master'
Your branch is behind 'origin/master' by 17 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Okay. This is it.
Step 10: Run git merge
$ git merge
Updating f43f71a..2529db8
Fast-forward
README.md | 3 +
add-ab_flags.f | 1741 ++++++++++++++++++++++++++++++++++++++++++++++++++++
addABWrapper.tcsh | 256 +++++---
do-ab.tcsh | 28 +-
do-ab_NOgsa.tcsh | 26 +
do-ab_gsa.tcsh | 29 +
6 files changed, 1975 insertions(+), 108 deletions(-)
create mode 100644 add-ab_flags.f
create mode 100755 do-ab_NOgsa.tcsh
create mode 100755 do-ab_gsa.tcsh
The merge finally works! Let's see what our git history looks like. Let's
run git log --oneline
$ git log --oneline
2529db8 (HEAD -> master, origin/master, origin/HEAD) @PeterEisenhardt
63d180e @PeterEisenhardt
7441259 Fixed Output Path
9629bdf Version 1.7 up to date!
8c9a6b2 Merge branch 'master' of https://github.com/catwise/AddABWrapper
abc6178 1\) use $5 in input list + input file 2\) added \-gsa 3\) make sure mdex and _af file path is different 4\) added rsync \(but not tested yet\!\!\!\)
72c8046 @PeterEisenhardt
0270f9e Merge branch 'master' of https://github.com/catwise/AddABWrapper
613feb2 added inputs $8 \(-n-m files path\) and $9\(temp2 files path\) to do-ab.tcsh
7f9b5c7 @PeterEisenhardt
fb6c00a @PeterEisenhardt
:
We now see that our branch master references the same commit as the remote-
tracking branch origin/master.
Closing thoughts
When I run git status, I still have untracked files.
Untracked files:
(use "git add <file>..." to include in what will be committed)
add-ab_flags20181214
add-ab_flags20181214.f
add-ab_flags2018oct04
addABWrapper2018dec14.tcsh
addABWrapper2018dec26.tcsh
addABWrapper2018oct04.tcsh
do-ab_20181214.tcsh
do-ab_20181214b.tcsh
do-ab_2018nov12.tcsh
do-ab_2018nov15.tcsh
do-ab_2018oct04.tcsh
do-ab_NOgsa2018dec26.tcsh
do-ab_gsa2018dec26.tcsh
gsa2018dec14
gsa2018oct04
It's not wise to keep these here. I'm going to put all of them in separate
branches named after their dates attached. I'm going to start on the commit
that master was originally on, f43f71a.
$ git checkout f43f71a
T gsa
Note: checking out 'f43f71a'.
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 f43f71a Update do-ab.tcsh
$ mv add-ab_flags20181214 add-ab_flags
$ mv add-ab_flags20181214.f add-ab_flags.f
$ mv do-ab_20181214.tcsh do-ab.tcsh
$ mv gsa2018dec14 gsa
override rwxr-xr-x root/admin for gsa? (y/n [n]) y
$ mv gsa2018dec14 gsa
override rwxr-xr-x root/admin for gsa? (y/n [n]) y
LMC-029695:AddABWrapper nrgarcia$ git status
HEAD detached at f43f71a
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: add-ab_flags
modified: do-ab.tcsh
modified: gsa
Untracked files:
(use "git add <file>..." to include in what will be committed)
add-ab_flags.f
add-ab_flags2018oct04
addABWrapper2018dec14.tcsh
addABWrapper2018dec26.tcsh
addABWrapper2018oct04.tcsh
do-ab_20181214b.tcsh
do-ab_2018nov12.tcsh
do-ab_2018nov15.tcsh
do-ab_2018oct04.tcsh
do-ab_NOgsa2018dec26.tcsh
do-ab_gsa2018dec26.tcsh
gsa2018oct04
$ git add add-ab_flags add-ab_flags.f do-ab.tcsh gsa
warning: LF will be replaced by CRLF in do-ab.tcsh.
The file will have its original line endings in your working directory
$ git checkout -b master_12_14_2018
M add-ab_flags
M add-ab_flags.f
M do-ab.tcsh
M gsa
$ git commit -m "Changes made on Dec. 14, 2018"
[master_12_14_2018 a606fc6] Changes made on Dec. 14, 2018
4 files changed, 1822 insertions(+), 18 deletions(-)
create mode 100644 add-a
$ git checkout -b master_12_14_2018b
Switched to a new branch 'master_12_14_2018b'
$ git add do-ab.tcsh
warning: LF will be replaced by CRLF in do-ab.tcsh.
The file will have its original line endings in your working directory
$ git commit -m "Alt. changes made on Dec. 14, 2018"
[master_12_14_2018b 268846e] Alt. changes made on Dec. 14, 2018
1 file changed, 4 insertions(+), 4 deletions(-)
$ git checkout -b master_2018oct04 f43f71a
Switched to a new branch 'master_2018oct04'
$ mv add-ab_flags2018oct04 add-ab_flags
$ mv do-ab_NOgsa2018dec26.tcsh do-ab_NOgsa.tcsh
$ mv do-ab_gsa2018dec26.tcsh do-ab_gsa.tcsh
$ mv gsa2018oct04 gsa
$ git add addABWrapper.tcsh do-ab.tcsh do-ab_NOgsa.tcsh do-ab_gsa.tcsh do-ab.tcsh
warning: LF will be replaced by CRLF in addABWrapper.tcsh.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in do-ab.tcsh.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in do-ab_NOgsa.tcsh.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in do-ab_gsa.tcsh.
The file will have its original line endings in your working directory
$ git commit -m "Changes made on Oct 4, 2018"
[master_2018oct04 6837730] Changes made on Oct 4, 2018
3 files changed, 57 insertions(+), 2 deletions(-)
create mode 100755 do-ab_NOgsa.tcsh
create mode 100755 do-ab_gsa.tcsh
$ git checkout -b 2018nov12 f43f71a
Switched to a new branch '2018nov12'
$ mv do-ab_2018nov12.tcsh do-ab.tcsh
$ git add do-ab.tcsh
warning: LF will be replaced by CRLF in do-ab.tcsh.
The file will have its original line endings in your working directory
$ git commit -m "Changes made on Nov. 12, 2018"
[2018nov12 5183159] Changes made on Nov. 12, 2018
1 file changed, 7 insertions(+), 3 deletions(-)
$ git checkout -b 2018nov15 f43f71a
Switched to a new branch '2018nov15'
$ mv do-ab_2018nov15.tcsh do-ab.tcsh
$ git add do-ab.tcsh
warning: LF will be replaced by CRLF in do-ab.tcsh.
The file will have its original line endings in your working directory
$ git commit -m "Changes made on Nov. 15, 2018"
[2018nov15 d80ca2d] Changes made on Nov. 15, 2018
1 file changed, 1 insertion(+), 1 deletion(-)
$ git checkout -b 2018dec26 f43f71a
Switched to a new branch '2018dec26'
$ mv addABWrapper2018dec26.tcsh addABWrapper.tcsh
$ git add addABWrapper.tcsh
warning: LF will be replaced by CRLF in addABWrapper.tcsh.
The file will have its original line endings in your working directory
$ git commit -m "Changes made on Dec. 26, 2018"
[2018dec26 d7a93ba] Changes made on Dec. 26, 2018
1 file changed, 155 insertions(+), 101 deletions(-)
$ git checkout -b 2018dec14 f43f71a
Switched to a new branch '2018dec14'
$ mv addABWrapper2018dec14.tcsh addABWrapper.tcsh
$ git add addABWrapper.tcsh
warning: LF will be replaced by CRLF in addABWrapper.tcsh.
The file will have its original line endings in your working directory
$ git commit -m "Changes made on Dec. 14, 2018"
[2018dec14 4b92ecf] Changes made on Dec. 14, 2018
1 file changed, 53 insertions(+), 47 deletions(-)
$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
$
We finally have a clean and working master branch. Any git pull will now
work without fault. All of the temporary changes we've made are also visible in
the different branches.
$ git branch
2018_12_11
2018dec14
2018dec26
2018nov12
2018nov15
* master
master_01_09_2019
master_12_14_2018
master_12_14_2018b
master_2018oct04
These branch names are pretty unhelpful, but I don't know what these changes do.
I ask that, whoever made these changes, determine if these branches should still
exist.
$ git log --oneline --graph --all
* 4b92ecf (2018dec14) Changes made on Dec. 14, 2018
| * d7a93ba (2018dec26) Changes made on Dec. 26, 2018
|/
| * d80ca2d (2018nov15) Changes made on Nov. 15, 2018
|/
| * 5183159 (2018nov12) Changes made on Nov. 12, 2018
|/
| * 6837730 (master_2018oct04) Changes made on Oct 4, 2018
|/
| * 268846e (master_12_14_2018b) Alt. changes made on Dec. 14, 2018
| * a606fc6 (master_12_14_2018) Changes made on Dec. 14, 2018
|/
| * f932964 (master_01_09_2019) Save unstaged
| * 4b12dbc Temporarily saved file
| * d51caef (2018_12_11) Update addABWrapper.tcsh
|/
| * 2529db8 (HEAD -> master, origin/master, origin/HEAD) @PeterEisenhardt
| * 63d180e @PeterEisenhardt
| * 7441259 Fixed Output Path
| * 9629bdf Version 1.7 up to date!
| * 8c9a6b2 Merge branch 'master' of https://github.com/catwise/AddABWrapper
| |\
| | * 72c8046 @PeterEisenhardt
| * 9629bdf Version 1.7 up to date!
| * 8c9a6b2 Merge branch 'master' of https://github.com/catwise/AddABWrapper
| |\
| | * 72c8046 @PeterEisenhardt
| * | abc6178 1\) use $5 in input list + input file 2\) added \-gsa 3\) make | * 9629bdf Version 1.7 up to date!
| * 8c9a6b2 Merge branch 'master' of https://github.com/catwise/AddABWrapper
| |\
| | * 72c8046 @PeterEisenhardt
| * | abc6178 1\) use $5 in input list + input file 2\) added \-gsa 3\) make
sure mdex and _af file path is different 4\) added rsync \(but not tested yet\!\!\!\)
| |/
| * 0270f9e Merge branch 'master' of https://github.com/catwise/AddABWrapper
| |\
| | * 7f9b5c7 @PeterEisenhardt
| * | 613feb2 added inputs $8 \(-n-m files path\) and $9\(temp2 files path\) to do-ab.tcsh
| |/
| * fb6c00a @PeterEisenhardt
| * 144420e @PeterEisenhardt
| * ab97305 Adding opt0/opt1 distinction to temp output
| * 56f4d37 @PeterEisenhardt
| * 96cbcb8 Update README.md
| * 861cdf4 @PeterEisenhardt
| * 0f00bb3 Update addABWrapper.tcsh
|/
* f43f71a Update do-ab.tcsh
* c671e98 changed directory calls for addABWrapper.tcsh, gsa, & add-ab_flags
* c1fbad4 Updated rsync step and added new files
* 200ea9b Update README.md