Contents
Started 26Oct2017, updated 15Apr2025. This page is in group Technology (plus My XMOS pages) and is a blog note about my usage of Git in the context of the XMOS xTIMEcomposer Studio.
Yes I know that GitHub and GitLab are two different companies. GitHub is even owned by Microsoft. And that Git is a sw tracking system developed by Linus Torvalds in 2005.
I am posting this here because I work alone, being retired and away from the guys I used to ask. Now I can ask this note!-) I have no Pull Requests to think about. So far I only have local Git repositories [1] and I have used GitHub only to fetch other people’s code.
I use Git because it’s nice to have the history at my fingertips. And GitHub is free as well.
Me on GitHub and GitLab
- GitHub: https://github.com/Aclassifier
- GitLab: https://gitlab.com/aclassifier
xTIMEcomposer .git repository directory
The Git repository directory is not visible in xTIMEcomposer. (The repository itself is of course visible, it’s in some of the Console view’s tabs). It is a hidden directory called .git (standard by Git), residing at the same level as bin and src. You will see it in Finder (I use a Mac) if you have made hidden directories visible:
In Sierra (macOS 10.12, 2016) it’s a keyboard shortcut, see How to show hidden files and folders including ~/Library on a Mac (Macworld):
Hold down Cmd + Shift + . (dot)
I just updated to High Sierra (from El Capitan) and it’s a beautiful function! And easy to remember: «make dot files visible or not»: cmd shift dot!
On older macOS (OS X) you’d have to do it in Terminal. It’s described in How to show hidden files in Finder (OS X 10.9)?
defaults write com.apple.finder AppleShowAllFiles 1
Using git commands to make a local git repository
I asked about this at the XCore Exchange forum (by XMOS): How to move files into newly made git repository
Aside (begin): git needs to be installed first
git
is part of MacOS Xcode
. So it should be there! However, when I in 2021 started using the 2010 Mac Mini with macOS Sierra 10.12.6, there was no Xcode
! And I couldn’t find any that old to install! Luckily I found How to Install Command Line Tools in Mac OS X (Without Xcode) from 2014 on OSXDaily (I now see the theme covered all over the place). The magic is the
xcode-select --install
and then do as the pop-up window says! It took some minutes to download the 130 MB (?) of code containing:
Command-line tools
Details
BuildStrings gcov pagestuff CpMac git projectInfo DeRez git-receive-pack ranlib GetFileInfo git-shell rebase MergePef git-upload-archive redo_prebinding MvMac git-upload-pack resolveLinks ResMerger gm4 rpcgen Rez gnumake segedit RezDet gperf size RezWack hdxml2manxml size-classic SetFile headerdoc2html strings SplitForks indent strip UnRezWack install_name_tool svn ar ld svnadmin as lex svnbench asa libtool svndumpfilter bison lipo svnfsfs bitcode_strip lldb svnlook c++ llvm-cov svnmucc c89 llvm-dsymutil svnrdump c99 llvm-dwarfdump svnserve cc llvm-nm svnsync clang llvm-objdump svnversion clang++ llvm-otool swift cmpdylib llvm-profdata swift-build codesign_allocate llvm-size swift-build-tool cpp lorder swift-demangle ctags m4 swift-package ctf_insert make swift-run dsymutil mig swift-stdlib-tool dsymutil-classic nasm swift-test dwarfdump ndisasm swiftc dyldinfo nm tapi flex nm-classic unifdef flex++ nmedit unifdefall g++ objdump unwinddump gatherheaderdoc otool xml2man gcc otool-classic yac
The day after I was asked to update, rather nice: Command Line Tools (macOS Sierra version 10.12) for Xcode 9.2. UPDATE. So now I have these: (but I didn’t check the previous versions):
xcode-select --version xcode-select version 2347. git --version git version 2.14.3 (Apple Git-98)
Aside (end)
The short answer is that it cannot be done from inside xTIMEcomposer. Larry wrote (I have modified line 2). To get to this then start Terminal and cd to the project directory (just below workspace) and run the commands:
If you turn individual projects inside your workspace into Git repositories, xTIMEcomposer will pick these up and give you a graphical interface to manage them:
git init git add Makefile src/*.xc src/*.c src/*.h src/*.cpp git add *.xn *.xscope
(list here or use «Add to index» in xTIMEcomposer later on)
git add .cproject .project git commit -m Initial
inside each project’s directory. You might not want the project files under source control, as they change quite frequently.
I added src/*.c.
When you gave done this you should have a .git directory at the same level as bin and src.
To tell xTIMEcomposer about it you’ll have to do Team | Share Project.. and select the new Git respository you just made. Alternatively «Add an existing local Git repository to this view» (see below) I guess. However, when I have done this and do Compare With | HEAD Revision then that HEAD revision is empty. But if I do a new Team | Commit and select files by hand (because they are all unticked of course) I do get a HEAD revision, without any diff… hmm. Maybe that initial HEAD revision should be empty?
Using GitHub Desktop to make a local git repository
It’s also possible to use the GitHub Desktop:
File | Add Local Repository
I then did a commit telling that it was first and that I had used the GitHub Desktop.
You will also have to tell xTIMEcomposer about this. I opened the Git Repositories tab in a Console view. I then did this:
I let xTIMEcomposer know where .git was. I could inspect the initial commit in the Git Reflog tab and there was the initial commit.
I then did a commit as usual in the IDE, on the project, like this:
Team | Commit
xTIMEcomposer Code Under Version Control
I found this by ahogen: https://gist.github.com/ahogen/93bf33ce47bb96c7fda60d844238fa43.
Quoted:
Do you need to keep your code under source/revision control with a solution like Git, Subversion (SVN), Mercurial? Are you using an Eclipse-based IDE like xTIMEcomposer (XMOS) or Code Composer Studio (Texas Instruments) and hate all the /.metadata
junk that should stay far away from your precous (sic) code?
New 13Apr2025. With the help from Edvard K. K.
A GitHub menu lets me select from these. Since I already have the code (like see a project at An encounter with AI-powered Cursor text editor and XC) I wonder if it’s Import reposirory I need to use?
|
Now I need to read xTIMEcomposer Code Under Version Control. But maybe not. Here is what we did:
Connecting my local code
- Using a web browser (Safari) made a new repository on GitHub, representing an xTIMEcomposer project. It’s just «rep» here:
- I kept it private since I only want to share it with some people
- The GitHub page then showed which GitHub commands to run in a terminal window at the xTIMEcomposer (XTC) project’s directory
- We tried Push BRANCH to Remote in XTC, but it failed on (→Can’t connect to any URI:..)
- git remote -v (→ nothing yet)
- git remote add origin https://github.com/Aclassifier/…git
- git remote -v
(→ origin https://github.com/Aclassifier/rep.git (fetch))
(→ origin https://github.com/Aclassifier/rep.git (push) - git push -u origin BRANCH_2024_09_05
(→ Username for ‘https://github.com’: Aclassifier
Password for ‘https://Aclassifier@github.com’:
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for ‘https://github.com/Aclassifier/rep.git/’) - We went to that URL and made a Personal access token (PAT).
In retrospect we probably should have used an SSH key instead, since it has the concept of private and public knowledge. See PAT vs. SSH – Why Bother with SSH? – which seems to agree on this, even if one comment says that «Signing is not the same as encrypting». - bash-3.2$ git push -u origin BRANCH_2024_09_05 (→ the branch of my HEAD revision)
(→ Username for ‘https://github.com’: nnn
Password for ‘https://Aclassifier@github.com’: (→ pasted in the Personal access token)
Counting objects: 4448, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4445/4445), done.
Writing objects: 100% (4448/4448), 1.98 MiB | 1.25 MiB/s, done.
Total 4448 (delta 3911), reused 0 (delta 0)
remote: Resolving deltas: 100% (3911/3911), done.
To https://github.com/Aclassifier/rep.git
* [new branch] BRANCH_2024_09_05 -> BRANCH_2024_09_05
Branch BRANCH_2024_09_05 set up to track remote branch BRANCH_2024_09_05 from origin. - → Now we could see my local project having been copied to the GitHub web
Testing a local change, commit and push
- To test we then made a change in a local file and commited it there
git status
(→ On branch BRANCH_2024_09_05
Your branch is ahead of ‘origin/BRANCH_2024_09_05’ by 1 commit.
(use «git push» to publish your local commits)Untracked files:
(use «git add …» to include in what will be committed)
(list of files)
nothing added to commit but untracked files present (use «git add» to track) - Then tried Push Upstream in XTC. It did not work
- git push
(→ Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 609 bytes | 609.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To https://github.com/Aclassifier/rep.git
f0cd8c4..91db161 BRANCH_2024_09_05 -> BRANCH_2024_09_05) - → The local edit correctly appeared on the web
Testing remote change and pull
- On the web I edited some in README.md
- git pull (in the local terminal window)
(→ remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (3/3), done.
From https://github.com/Aclassifier/xc_Beep_BRRR_02
d56328a..b9dd0db BRANCH_2024_09_05 -> origin/BRANCH_2024_09_05
Updating d56328a..b9dd0db
Fast-forward
README.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 README.md) - git status
(→ On branch BRANCH_2024_09_05
Your branch is up-to-date with ‘origin/BRANCH_2024_09_05’.Untracked files:
(use «git add …» to include in what will be committed)
(list of files)
nothing added to commit but untracked files present (use «git add» to track)) - → The web edit correctly appeared in my local editor
Comments
- The «untracked files present» messages appeared because I didn’t have a .gitignore file. According to my specialist this file is a standard file and must therefore be present in the repository. The fix:
- git add of each of the files or directories that I wanted to include
- I made a .gitignore file with two lines:
.DS_Store
.build/
(The TextEdit app at first wanted some file attribute, like .txt. But once I removed the .txt in Finder, TextEdit would both open and save it as .gitignore) - git add .gitignore
- I commited in XTC
- Then synched to GitHub:
- git push
(→ Counting objects: 19, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (19/19), 976.15 KiB | 3.14 MiB/s, done.
Total 19 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/Aclassifier/rep.git
b9dd0db..c834423 BRANCH_2024_09_05 -> BRANCH_2024_09_05) - git status
(→ On branch BRANCH_2024_09_05
Your branch is up-to-date with ‘origin/BRANCH_2024_09_05’.nothing to commit, working tree clean)
-
- …
So that I won’t forget
-
-
- Comment on foobaz/sqrt.c – my comment 31Aug2024
-
References
[1] Pro Git by Scott Chacon and Ben Straub and published by Apress, 2nd Edition (2014) https://git-scm.com/book/en/v2. «With corrections and additions from hundreds of contributors.» You can read it online or download a PDF. Available in many languages