Git can be confusing in the beginning, for sure. Later on, there are advanced git things that can also be very confusing, for sure.
These commands are not monolithic, inscrutable texts - these are commands with meanings.
Comparing your first ones: git clone --depth=1 https_url
and git clone https_url
, again, just understand the difference. I’ve never used the “depth” flag before. So, I would google “git clone” and I get lead here. In there, I can read:
-- depth <depth>
Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch
unless --no-single-branch
is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules
.
OK, so it is telling you that instead of downloading the entire commit history, you can specify how deep to go.
I would work through it like that. Understand what it is saying.
Jessica mentioned being careful about using git reset --hard
.
Yes, messing with the git history is always tough. The “hard” flag will also remove any changes you made since the commit to which you are resetting. It’s fine if that is what you want, but be careful.
For the git commands that I colored blue, are they only for when you first clone the repo, or should I repeatedly use them?
Again, it depends. They could all be used at any point, depending on what you want.
Now that I have cloned the repo, can I use the Second set of commands which Jessica gave me?
Sure, I guess, depending on what you want.
In time I will understand all the commands, but in the time being, I would like to have a list of the commands I need to do to contribute.
I would not recommend using a git command unless you know what it is doing. You can do a lot of damage with sloppy git commands. I’m not saying you need to master git before proceeding, but at least understand what you are doing. Don’t just cut and paste git commands and hope for the best.
There are plenty of videos out there. There is also a great book called Mastering Git. It is a free ebook. It gets pretty advanced, but the first chapters go through a lot of interesting technical details.