[TUT][SOFT] Using Git with Atmel Studio 7

Go To Last Post
7 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I have seen the posts on AVRFreaks regarding git and AS7 integration. While Visual Studio does integrate very nicely with git, unfortunately that didn't extend to AS7 (which is based on Visual Studio). There is, however, a very efficient and workable solution.


Prior to git, I used SVN with the TortoiseSVN File Explorer extension. Since it seemed like the "world was moving to git", I decided to make the switch myself when I saw that the "Tortoise group" (lacking a better term) also supplied TortoiseGit.


It's free, and works perfectly. (I've contributed to them, and if you try it out and find it as useful as I have, I hope that you'll help support the effort as well.) I hope that you'll agree that having it integrated into the File Explorer really does make up for the fact that it isn't integrated in AS7. This includes pushes, pulls, diffs, branches, etc.


When I looked around for free repositories, I decided to use Visual Studio Team Services (VSTS) instead of GitHub. (I wanted a place to store my code, not begin a new open source project.) VSTS is free to teams of up to 5 people, and has no down-side thus far. Their link is:



You'll need to set up an account (which is free); this step is required wherever you go.


[Note that I refer to VSTS below when referencing actions involving the Git repository; you'll need to perform the equivalent step with whatever remote repository you've chosen.]


You'll find TortoiseGit at:



Once you've installed it, here is a detailed list of steps to begin using it with AS7:


1. In File Explorer, navigate to an existing project, or create a new project in AS 7.


2. Create new team project on Visual Studio Team Services. As you'll see later, the project names do not need to match; each can have its own naming convention if needed.


3. Navigate to AS 7 project folder; right click on folder name, click Git Create repository here... Leave "Make it Bare" unchecked. This will create the .git folder within the AS 7 project folder.


4. Create a new text file gitignore.txt; copy into it the contents found at the bottom of this post. (Alternately, I will also post a gitignore-AS7.txt example file on my SiliconHacker.com website later.)


4a. Save and close the file, then rename it:

          gitignore.txt to .gitignore.  (<-- note trailing dot!)


Windows will automatically drop the trailing dot from the filename. [Alternately, you can copy the file from another known-good "git-prepared" project.]


5. Right click on AS 7 project folder, launch Git Commit -> "master". Enter your commit Message (something like "Initial local add and commit". Ensure Show Unversioned Files checked; Select all files by clicking All.


5a. Review the list. It should automatically include all folders/files which are not explicitly excluded by .gitignore, so whatever file-system hierarchy you've set up is maintained.


6. Click Commit; close dialog. By this point, the initial fileset has been added and commited to the local store; you still don't that a remote repository.


7. Right click on AS 7 project folder, launch Git Sync... This is where we map the local store to the remote (server) repository. [AS mentioned above, the local AS 7 project does *NOT* need to have the same name as the remote repository.]


8. In the Git Sync dialog, the Local branch will be set to master; the Remote entry field will be empty.


9. Click on the Manage button at the right end of the Remote URL field; this opens the Git Remote Setting dialog.


10. From the Git Remote Setting dialog, enter the name of the AS 7 project into the Remote field in the upper right of the Remote panel.


11. From the remote repository UI (VSTS), navigate to the project you set up in step 2. (It will be empty, of course, since you've not done the first push to it.)


12. Copy the Clone URL for the project as supplied by whatever remote repository you've chosen.


13. Copy the Clone URL from step 12 into the URL and Push URL fields in the Remote panel of the Git->Remote dialog.


14. Click Add New/Save; click OK to close. You have now created a local project name alias to a remote repository URL.


15. The AS 7 project alias is now in the Remote URL field.


16. The GIT dialog is still open. Click the Push button. Answer Yes to the dialog asking "For the current branch "master" no tracked branch ...". The AS 7 project is now copied into the remote repository and is fully current with the local copy. Click Close.


17. Refresh the contents of the remote repository. You should see a copy of all tracked files from the AS 7 local project folder within the VSTS project.


18. Review your project in File Explorer; you'll now notice that every tracked file and folder has a green overlay icon (which indicates that it is current with the store). That icon turns red when the folder/file is out-of-sync.



At this point, your AS7 project has both a local and a remote repository, and you have the full features of the Git source control to track changes, etc.



As I mentioned above, TortoiseGit is integrated with the File Explorer and that is how you'll continue to interact with it.



1. Make an edit to one of the files; ensure the edited file has been saved back to the file system.


2. To commit folder/file changes to the local store, simply right click on the folder/file to activate the context menu. You'll see

          Git Commit -> "master"...



3. Most of the time, you'll use Commit. When clicked, it opens a dialog into which you'll enter your commit comment. Confirm in the commit dialog that the file is detected as having been changed.


4. Ensure that same file is checked in the Change made... pane.


5. Click Commit to commit the change to the local repo. [This does not push those changes to the remote repo.]


6. Right click on folder/file again; launch Git Sync... This activates the Git Synchronization from local to remote dialog. Confirm that the message entered when committing the edited file is the same as the message entered in step 3.


7. Click Push; click Close.


8. You should now be able to see your changes in the remote repository.



I hope that this post is useful to you and provides a good start for anyone wanting a reliable, free, version control system for their code. And, no, I'm not here getting into branching... Sorry.




EDIT Aug 8, 2017:


I realized that I forgot to mention something that is really one of the most useful reasons to save files in a source repo in the first place: diff. Here is a quick note on how to diff folders/files with TortoiseGit.


From the File Explorer, you'll see the red exclamation point icon on the folder/file; these indicate all out-of-sync folders/files relative to the local repo. Right click; you'll now see the TortoiseGit item as the last item in the context menu. Hover over the item to activate the large (second-level) context menu. Near the top, you'll see Diff; select.


That activates a new dialog which lists all of the out-of-sync files; double click one to select. That will activate a two-pane view of the file. In the left pane will be the file as it current exists in your AS7 project; the right pane is the current version stored in the local repo. Once you've reviewed the diff, you can close the file.


To commit the diff, simply click Commit at the bottom of the list dialog.




Here is the contents of the .gitignore file which has been compatible with AS7 (at least so far):



## Ignore Atmel/Visual Studio temporary files, build results, and

## files generated by popular Visual Studio add-ons.


# User-specific files






# Build results












# Atmel/Visual Studio cache/options directory




























# Visual C++ cache files










# Visual Studio profiler






# Visual Studio cache files

# files ending in .cache can be ignored


# but keep track of directories ending in .cache



# Visual Studio 6 build log



# Visual Studio 6 workspace options file





EDIT Sep 5, 2017:


While setting up GIT for my hardware files, I realized that I left out one step that may confuse the new user. TortoiseGIT requires a previous installation of one of the GIT implementations for Windows in order to work. The one it recommends (during post install, actually) is "git for windows":




The simplest process is to install git-for-windows first, then TortoiseGIT. During the post-install, TortoiseGIT will know where to look for git-for-windows. Once it finds the git install, you're good to go.

The SiliconHacker  Plano, TX  www.siliconhacker.com

Last Edited: Tue. Sep 5, 2017 - 07:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Great post. Should I move it to the Tutorial Forum?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note that it is not necessary to integrate into the IDE (whether AS or whatever) in order to use revision control effectively.

Personally, I prefer to just do it in the file system - using the likes of TortoiseSVN, TortoiseGit, et al - so the IDE is none the wiser.


But it is quite a frequent request - so hopefully this will be helpful.


Phoenix710 wrote:
... instead of GitHub. (I wanted a place to store my code, not begin a new open source project.) 

Note that it is not necessary to make your GitHub projects public.


.gitignore.  (<-- note trailing dot!) 

Is that a specific AS/VS thing?


The Git projects I have (none of which is AS nor VS related) all just use .gitignore - without any trailing dot.



  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, please. Thanks much.


The SiliconHacker  Plano, TX  www.siliconhacker.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please reread step 4a again. The trailing dot is needed to create the file; it is then renamed. You can't create a file with a dot but no extension; the rename is the trick that makes it work. It's really a window's file system constraint.

The SiliconHacker  Plano, TX  www.siliconhacker.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh - I see


  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I hit exactly the same thing the other day. My own solution was to simply use DOS commands in a Command Prompt. The trailing dot thing is a great idea.

(I was trying to create a folder called .ssh to add an RSA key for use with Gerrit as an interface to Git, that's well worth exploring too)