<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Git checkout onto a branch from origin does not work. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Git-checkout-onto-a-branch-from-origin-does-not-work/m-p/834070#M329754</link>
    <description>&lt;P&gt;Hi Alex,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently facing exactly the same issue.&lt;/P&gt;&lt;P&gt;As you posted quite a long time ago and there seems to have been no answer, I am wondering whether you solve it ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KR,&lt;/P&gt;&lt;P&gt;Etienne&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Sep 2022 12:09:39 GMT</pubDate>
    <dc:creator>baertman</dc:creator>
    <dc:date>2022-09-19T12:09:39Z</dc:date>
    <item>
      <title>Git checkout onto a branch from origin does not work.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Git-checkout-onto-a-branch-from-origin-does-not-work/m-p/682178#M206479</link>
      <description>&lt;P&gt;In both SAS Viya and SAS 9.6 M6 (Enterprise guide) I have the following problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can successfully clone an online repository with multiple branches onto my SAS server location using either GIT_CLONE or GITFN_CLONE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I cannot checkout onto an existing branch using onto that branch name.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;GITFN_CO_BRANCH( "path_to_repo", "v1Harry")&lt;/P&gt;&lt;P&gt;This tells me that:&lt;/P&gt;&lt;P&gt;ERROR: Return code from GIT is (4). revspec 'v1Harry' not found&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when we change to:&lt;/P&gt;&lt;P&gt;GITFN_CO_BRANCH( "path_to_repo", "origin/v1Harry")&lt;/P&gt;&lt;P&gt;This works:&lt;/P&gt;&lt;P&gt;NOTE: Branch "origin/v1Harry" successfully checked out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the big problem now comes when we do a gitfn_status:&lt;/P&gt;&lt;P&gt;NOTE: Entry: README.md. Staged: True. Status: New.&lt;BR /&gt;NOTE: Entry: master_script.sas. Staged: True. Status: New.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Despite all files being on the branch online in the origin - git now thinks they are new.&lt;/P&gt;&lt;P&gt;This creates a huge problem if the repo has hundreds of files - it is nearly impossible to add them all back in as SAS has not allowed for git -A functionality in the GITFN_IDX_ADD function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally let's say we go through the process of adding all these (unchanged files...) again and we commit and push from "origin/v1Harry"...&lt;/P&gt;&lt;P&gt;If we do this in SAS 9.4 we get this error:&lt;/P&gt;&lt;P&gt;ERROR: Return code from GIT is (9). object not found - no match for id (484541442f686f6d652f616c657867772f736173)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we do this in Viya, then rather than branch v1Harry being updated on the origin, instead a new branch is created on the origin called "origin/v1Harry"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I doing something wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help of advice would be most welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BW,&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 09:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Git-checkout-onto-a-branch-from-origin-does-not-work/m-p/682178#M206479</guid>
      <dc:creator>AlexGW</dc:creator>
      <dc:date>2020-09-08T09:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Git checkout onto a branch from origin does not work.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Git-checkout-onto-a-branch-from-origin-does-not-work/m-p/834070#M329754</link>
      <description>&lt;P&gt;Hi Alex,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently facing exactly the same issue.&lt;/P&gt;&lt;P&gt;As you posted quite a long time ago and there seems to have been no answer, I am wondering whether you solve it ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KR,&lt;/P&gt;&lt;P&gt;Etienne&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 12:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Git-checkout-onto-a-branch-from-origin-does-not-work/m-p/834070#M329754</guid>
      <dc:creator>baertman</dc:creator>
      <dc:date>2022-09-19T12:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Git checkout onto a branch from origin does not work.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Git-checkout-onto-a-branch-from-origin-does-not-work/m-p/834078#M329760</link>
      <description>&lt;P&gt;well, I found a workaround but do not find it a suitable solution at long term.&lt;/P&gt;&lt;P&gt;Once I've cloned the repository, I am copying the ref from remotes/origin to heads within the local git metadata:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;filename frefin&amp;nbsp; "&amp;amp;path.\.git\refs\remotes\origin\&amp;amp;targetBranch";
filename frefout "&amp;amp;path.\.git\refs\heads\&amp;amp;targetBranch";

data _null_ ;
&amp;nbsp; &amp;nbsp; &amp;nbsp;rc = fcopy('frefin', 'frefout');
&amp;nbsp; &amp;nbsp; &amp;nbsp;msg = sysmsg();
&amp;nbsp; &amp;nbsp; &amp;nbsp;put rc= msg=;
run;&lt;/PRE&gt;&lt;P&gt;and then successfully checking out the &amp;amp;targetBranch.:&lt;/P&gt;&lt;PRE&gt;data _null_;
&amp;nbsp; &amp;nbsp; &amp;nbsp;rc = git_branch_chkout("&amp;amp;path.", "&amp;amp;targetBranch.");
&amp;nbsp; &amp;nbsp; &amp;nbsp;put rc = ;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Sep 2022 12:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Git-checkout-onto-a-branch-from-origin-does-not-work/m-p/834078#M329760</guid>
      <dc:creator>baertman</dc:creator>
      <dc:date>2022-09-19T12:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Git checkout onto a branch from origin does not work.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Git-checkout-onto-a-branch-from-origin-does-not-work/m-p/861915#M340432</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Create a local branch with the same name as the remote branch.&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/egug/8.3/p1hpe5eorqrm7yn1ccx4jjq81sqp.htm" target="_blank" rel="noopener"&gt;Checking Out Branches&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;For example&amp;nbsp;"dev" if you have remote branch "origin/dev".&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Checkout newly created local "dev" branch.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Then when you pull changes it puls form remote "origin/dev".&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;data _null_;
   version = gitfn_version();        
   put version=;                   
run;

%let l_git_repo               = 'C:\Git\xxxxxxx';
%let l_git_uri                = 'https://?????/xxxxxxx.git';
%let l_git_user               = '???????';
%let l_git_pw                 = '{SAS005}???????';


/* Delete REPO  */
data _null_;
   rc = GITfn_DEL_REPO(&amp;amp;git_repo.);
   put rc=;
run;

/* Clone Repo */
data _null_;
   rc = GIT_CLONE (&amp;amp;l_git_uri., &amp;amp;l_git_repo., &amp;amp;l_git_user., &amp;amp;l_git_pw.);
   put rc=;
run;


/* Get Branch commit id from remote*/
%let l_git_branch             = 'dev';
%let l_git_branch_commit_id   = NA;
data _null_;
   infile %sysfunc(quote(%sysfunc(dequote(&amp;amp;l_git_repo.))/.git/refs/remotes/origin/%sysfunc(dequote(&amp;amp;l_git_branch.))));
   input;
   call symputx( 'l_git_branch_commit_id',quote(cats(_infile_)),'l');
   stop;
run;
%put &amp;amp;=l_git_branch_commit_id.;

/* create new local branch */ 
data _null_;
   rc = git_branch_new(&amp;amp;l_git_repo., &amp;amp;l_git_branch_commit_id., &amp;amp;l_git_branch., 0); 
   put rc=;
run;

/* chkout local branch */ 
data _null_;
   rc= git_branch_chkout(&amp;amp;l_git_repo.,&amp;amp;l_git_branch. );  
   put rc=;
run;

/* pull changes */ 
data _null_;
   rc= git_pull(&amp;amp;l_git_repo., &amp;amp;l_git_user., &amp;amp;l_git_pw.);             
   put rc=;                            
run;


&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 10:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Git-checkout-onto-a-branch-from-origin-does-not-work/m-p/861915#M340432</guid>
      <dc:creator>littan</dc:creator>
      <dc:date>2023-03-02T10:09:08Z</dc:date>
    </item>
  </channel>
</rss>

