My Git/GitHub/GitLab notes

Started 26Oct2017, updated 31Aug2024

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.

Fold handling with Collapse-O-Matic plugin

Expand All (for browser searching)
Collapse All

Typical fold

This text 123456789 will only be found with browser search when the fold is expanded. However, the search field on the top of this page is global for all notes, (expanding) all containing folds during the search. More precise: pages in that case will not have any collapsed state.

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 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.

GitHub and GitLab

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

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:

Add an existing local Git repository to this view

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?

So that I won’t forget

References

Wikipedia: Git

Leave a Reply

Dette nettstedet bruker Akismet for å redusere spam. Lær om hvordan dine kommentar-data prosesseres.