libgit2sharp | Git + NET = ❤ | DevOps library
kandi X-RAY | libgit2sharp Summary
kandi X-RAY | libgit2sharp Summary
Git + .NET/Mono =
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of libgit2sharp
libgit2sharp Key Features
libgit2sharp Examples and Code Snippets
Community Discussions
Trending Discussions on libgit2sharp
QUESTION
I am trying to push a commit I made on my local repository to a remote counterpart, hosted on a private Azure DevOps server, using LibGit2Sharp programmatically.
As per the Azure documentation, the HTTPS OAuth enabled Personal Access Token needs to sent with the request in a custom Authentication header as 'Basic' with the Base64 encoded token:
...ANSWER
Answered 2022-Mar-10 at 04:54I will provide an answer to my own question as we have fixed the problem.
The solution to this is really simple; I just needed to remove the CredentialsProvider
delegate from the PushOptions
object, that is:
QUESTION
I am writing a program that manipulates a git repo using the LibGit2Sharp library. One of the operations that I need to perform is a rebase to incorporate changes made to the master into a branch. How do I perform a git rebase master
command using LibGit2Sharp? I haven't been able to find any examples of this.
ANSWER
Answered 2021-Nov-11 at 09:27What about something like
QUESTION
Currently trying to clone a gitlab repository (which can only be accessed by VPN). A normal access (without vpn) through a gitlab repo works with libgit2sharp.
...ANSWER
Answered 2021-Feb-12 at 05:08I was able to clone git repository by using the command:
QUESTION
I need to push a local folder to a Git repository. Following is what I have tried till now:
...ANSWER
Answered 2021-Jan-28 at 14:59How can I use GitHub PAT token for this Push?
Set that as your password to the credentials provider. A PAT is a password.
And if you've used your actual password in your question, please change it immediately.
QUESTION
I need to capture the full output from Git that results from a Push operation so that I can parse the error if needed.
Outside of LibGit2Sharp this could be done by redirecting the StandardError.
Is there a way to achieve this in the current library state? I looked through the classes and it seems that right now this is being obfuscated. Hopefully I missed something?
...ANSWER
Answered 2020-Sep-05 at 03:04LibGit2Sharp is a wrapper around libgit2, which is a C library that reimplements Git functionality. It's an independent library and doesn't use Git under the hood.
However, there are ways to use libgit2 to get information from the remote. Since I was unable to quickly find a web page with documentation for LibGit2Sharp, I'll show you the libgit2 documentation, and let you figure out what that looks like in .NET.
When you push with libgit2, you can specify a set of callbacks that the library can provide when certain events occur. This can be used to provide progress or other status information. The struct documentation indicates a member called sideband_progress
, which is the callback for textual output that the remote side sends. In a normal git push
invocation, that's the lines beginning with remote:
.
Any time the remote side sends a complete line, that callback will be invoked and you'll get that output. Do note that often the output contains a carriage return to overwrite the previous entry and that the callback may be invoked a significant number of times, which may impact how you wish to store and process the output.
Now, having said that, the ideal way to get your data is by using the error code from the library, since that's going to be the easiest and most reliable way to get data. Parsing error messages is tricky; if you're talking to an arbitrary Git server, it's not guaranteed that it will use the same error messages as Git does, or even that any output it produces will be in English. Sometimes, though, you can't avoid it, so if that's the case, you now know how to do it.
QUESTION
I'm using the GitHub API in a C# webapp (with Blazor). I want to be able to create a single commit to add, delete, and edit multiple files in a folder in a repository. I know I can send a PUT request to the URL https://api.github.com/repos/[username]/[repository]/contents/[file]
with these contents to create a file (and I can also edit a file by adding an SHA hash):
ANSWER
Answered 2020-May-09 at 22:53Is there any way that I can do multiple operations in a single commit (either using the GitHub API or something else)?
There is the underlying Git Data API that can be used to build up a commit from scratch:
- files are uploaded as blobs using the API
- trees are used to indicate what the repository state should be (update paths to point to the new blobs)
- then create a new commit using the new root tree and additional metadata
- if you can, then update the reference (i.e. the branch) to point to this new commit
QUESTION
We are using GIT for deployment and it's all working splendidly. At the moment I'm writing functionality to allow a client to switch to another Deployment repository - after all we may at some point decide to start deploying from a different location, right?
We create the repository in Azure and we Generate GIT Credentials using the button after creating the Repository:
So I present the user with a form where they can enter a new URL, a Username and a Password, and then I go check .... (vb.net code)
...ANSWER
Answered 2020-Apr-11 at 09:00Is this a bug in dev.azure.com's way of doing GIT? Why have a "username" at all if it > > gets ignored anyway?
Nope, this is the expected action since you are using Git Credential Manager (GCM)
to generate the password.
In fact, it is not an officially password. What it generated is a Personal access token after you click the button Generate Git Credentials
, and its scope only to Repos(Read&Write)
.
At this time, go Security
(https://dev.azure.com/{orgname}/_usersSettings/tokens) page, you will see there has one token be added which Token name
is like git: https://dev.azure.com/{orgname} on {machine platform}.
For Personal access token, I'm sure you'd known that the PAT token are tied to a single user account when it generated. In another word, you doon't need input the username additionally while using PAT as authorize method. That's why the username get ignored anyway.
You can also check this doc to get How the Git Credential Managers works
Is this something I need to worry about?
Just treat it as password to keep secret will not cause too much issue.
Most of time, you don't need worry it. Because this token will expired very soon, will not longer than 1 day.
Also, as I mentioned above, the scope of this token are only to Repos with Read&Write
permission. Even if someone accidentally gets this token, they can not make operation outside the Repos.
QUESTION
Noticed something strange.... I'm using libgit2sharp to clone a repository. The clone command is pretty straightforward
...ANSWER
Answered 2020-Apr-02 at 08:15Ok so the solution to this problem consisted of two parts. Firstly, as colinD already suggested in his comment I had to go and change the configuration. Which I did. But it still didn't work for me. The reason was that the last time I committed and pushed my .sql files it had already replaced all line endings with LF in the remote repository. So I removed all the SQL files, commmitted and pushed the removal, re-added them, committed and pushed the re-added sql files, and then it worked.
As suggested by @EdwardThomson in his comment I then reverted back to the default settings and I added a .gitignore file instead. In the .gitignore file - at the same level as the .git folder in Windows - I added
QUESTION
I am writing a dotnet api to clone from github, then push a specific branch to AWS codecommit using the Libgit2sharp library.
- I have two branches in the gitHubRepo, origin/release and origin/refactor.
- origin/release is the DEFAULT git branch
- I want to clone the gitHubRepo, and push the origin/refactor branch to codecommit
Problem: I can't seem to get it to push my specified branch to codecommit, it always seems to push what is set to HEAD. I don't know how to change the HEAD, or even know if this is the issue.
Code Snippet:
...ANSWER
Answered 2020-Mar-28 at 05:54Try and use a complete refsepc when pushing
The format of a
parameter is an optional plus
+
, followed by the source object, followed by a colon
:
, followed by the destination ref.
In your case:
QUESTION
I'm using LibGit2Sharp to clone a repository into a local folder. I know I could simply use Brute Force and delete the .git folder afterwards, and that will certainly achieve what I set out to achieve, but it's not the most elegant way to address this. If I deleted the .git folder I would have to clone it again at a later stage. I want to easily "switch" between branches but it becomes a slow and laborious process if every time I have to re-clone it before I can do that.
What I would like to do is to, after Cloning the repository, .... and here is where I don't know the correct terminology. what.... "log out"? "disconnect the credentials"? I don't know. Basically, what I want to achieve is that after the Clone a user cannot simply go and start messing about with the files and Push them back up to the remote repository, but I can't find any clear answers online about how to "clear credentials". I'm looking to do so programmatically, obviously.
Sorry. As this isn't clear in my own head I don't know how to ask this properly. I hope I described it clearly enough for someone to know how to answer this.
Answers in C# or VB.NET welcome ...
Regards
Pino
...ANSWER
Answered 2020-Mar-04 at 16:26There is no need to "log out" in any way, shape or form. The remote repository remains inaccessible without credentials, even if the user installs GIT or TortoiseGit or some such. So I worried for no good reason.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install libgit2sharp
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page