building scala from git

Moderator: frogmaker

frogmaker
Moderator
Moderator
Posty: 55
Rejestracja: 06 maja 2018, 12:57

building scala from git

Post autor: frogmaker »

Kod: Zaznacz cały

 git clone -b upstream/v0.18.3.4 https://github.com/scala-network/Scala.git  

Kod: Zaznacz cały

git log
git status

Kod: Zaznacz cały

cd Scala
mkdir build && cd build
cmake ..
make -j 10
update branch:

Kod: Zaznacz cały

git pull
switch branch:

Kod: Zaznacz cały

git checkout upstream/v0.18.4.0
frogmaker
Moderator
Moderator
Posty: 55
Rejestracja: 06 maja 2018, 12:57

Re: building scala from git

Post autor: frogmaker »

Before answering, let's add some background, explaining what this HEAD is.
First of all what is HEAD?

HEAD is simply a reference to the current commit (latest) on the current branch.
There can only be a single HEAD at any given time (excluding git worktree).

The content of HEAD is stored inside .git/HEAD and it contains the 40 bytes SHA-1 of the current commit.
detached HEAD

If you are not on the latest commit - meaning that HEAD is pointing to a prior commit in history it's called detached HEAD.

On the command line, it will look like this - SHA-1 instead of the branch name since the HEAD is not pointing to the tip of the current branch:

A few options on how to recover from a detached HEAD:

Kod: Zaznacz cały

git checkout

git checkout <commit_id>
git checkout -b <new branch> <commit_id>
git checkout HEAD~X // x is the number of commits to go back
This will checkout the new branch pointing to the desired commit.
This command will checkout to a given commit.
At this point, you can create a branch and start to work from this point on.

# Checkout a given commit.
# Doing so will result in a `detached HEAD` which mean that the `HEAD`
# is not pointing to the latest so you will need to checkout branch
# in order to be able to update the code.

Kod: Zaznacz cały

git checkout <commit-id>
# Create a new branch forked to the given commit

Kod: Zaznacz cały

git checkout -b <branch name>

Kod: Zaznacz cały

git reflog
You can always use the reflog as well.
git reflog will display any change which updated the HEAD and checking out the desired reflog entry will set the HEAD back to this commit.

Every time the HEAD is modified there will be a new entry in the reflog

Kod: Zaznacz cały

git reflog
git checkout HEAD@{...}
This will get you back to your desired commit

Enter image description here

Kod: Zaznacz cały

git reset --hard <commit_id>
ODPOWIEDZ