Git: Difference between revisions

103 bytes added ,  11 August 2023
m
no edit summary
Tag: visualeditor
mNo edit summary
Tag: visualeditor
Line 1: Line 1:
{{DISPLAYTITLE:git}}
{{DISPLAYTITLE:git}}
= Signing work =
 
== Setting the initial config variables ==
 
== Signing work ==


Get your GPG configured, and a personal key installed.  Configure Git to use your personal key.
Get your GPG configured, and a personal key installed.  Configure Git to use your personal key.
Line 8: Line 11:
</source>
</source>


== Signing commits ==
=== Signing commits ===


You can sign commits simply by adding -S once your environment is configured.
You can sign commits simply by adding -S once your environment is configured.
Line 42: Line 45:
</source>
</source>


= Workflows =
== Workflows ==


== Making a pull request ==
=== Making a pull request ===


1. Fork the project
1. Fork the project
Line 114: Line 117:
== Accepting and merging a pull request ==
== Accepting and merging a pull request ==


= Commands =
== Commands ==


== Add ==
=== Add ===


Add only modified and deleted files:
Add only modified and deleted files:
Line 124: Line 127:
</source>
</source>


== Tags ==
=== Tags ===


Signing tags:
Signing tags:
Line 171: Line 174:
* Reference: [https://www.xspdf.com/resolution/50066178.html#:~:text=Git%20get%20latest%20tag%20on%20current%20branch&text=To%20get%20the%20latest%20annotated,%2Dmatch%20%2D%2Dabbrev%3D0. Tag-related commands]
* Reference: [https://www.xspdf.com/resolution/50066178.html#:~:text=Git%20get%20latest%20tag%20on%20current%20branch&text=To%20get%20the%20latest%20annotated,%2Dmatch%20%2D%2Dabbrev%3D0. Tag-related commands]


== Clone a specific branch ==
=== Clone a specific branch ===


<source lang="bash">
<source lang="bash">
Line 177: Line 180:
</source>
</source>


== Get a build number ==
=== Get a build number ===


A commit count can be used as a build number for a revision (e.g. HEAD, master, a commit hash):
A commit count can be used as a build number for a revision (e.g. HEAD, master, a commit hash):
Line 197: Line 200:
</source>
</source>


== Add a local branch that tracks a remote branch ==
=== Add a local branch that tracks a remote branch ===


<source lang="bash">
<source lang="bash">
Line 205: Line 208:
</source>
</source>


== Pulling changes from a remote ==
=== Pulling changes from a remote ===


<source lang="bash">
<source lang="bash">
Line 226: Line 229:
</source>
</source>


== Rebase a branch ==
=== Rebase a branch ===


<source lang="bash">
<source lang="bash">
Line 241: Line 244:
</source>
</source>


== Start a new branch ==
=== Start a new branch ===


<source lang="console">
<source lang="console">
Line 248: Line 251:
</source>
</source>


== Merge a branch ==
=== Merge a branch ===


<source lang="console">
<source lang="console">
Line 264: Line 267:




== Rename a branch ==
=== Rename a branch ===


and update in the remote as well
and update in the remote as well
Line 278: Line 281:
</source>
</source>


== Delete a branch ==
=== Delete a branch ===


* Delete a local branch
* Delete a local branch
Line 298: Line 301:
</source>
</source>


== List merged branches ==
=== List merged branches ===


List branches merged into master
List branches merged into master
Line 318: Line 321:
</source>
</source>


== Undo last commit ==
=== Undo last commit ===


This undo is recorded as a part of the git log.
This undo is recorded as a part of the git log.
Line 326: Line 329:
</source>
</source>


== Fix or amend last commit ==
=== Fix or amend last commit ===


<source lang="bash">
<source lang="bash">
Line 332: Line 335:
</source>
</source>


== Undo changes to a file ==
=== Undo changes to a file ===


<source lang="bash">
<source lang="bash">
Line 338: Line 341:
</source>
</source>


== Reset the branch to a specific point in the past ==
=== Reset the branch to a specific point in the past ===


<source lang="bash">
<source lang="bash">
Line 346: Line 349:
--hard parameter also updates the working directory. Reset shouldn't be used in a group project on a remote repository because of its potential for confusion.
--hard parameter also updates the working directory. Reset shouldn't be used in a group project on a remote repository because of its potential for confusion.


== Reset the branch to a specific branch on a remote ==
=== Reset the branch to a specific branch on a remote ===


<source lang="bash">
<source lang="bash">
Line 352: Line 355:
</source>
</source>


== Ignore files ==
=== Ignore files ===


;Temporary ignore changes to a file
;Temporary ignore changes to a file
Line 372: Line 375:
</source>
</source>


== Ignore file modes ==
=== Ignore file modes ===


This is useful when working with multiple file systems.
This is useful when working with multiple file systems.
Line 380: Line 383:
</source>
</source>


== Maintenance command ==
=== Maintenance command ===


Verify the connectivity and validity of the objects
Verify the connectivity and validity of the objects
Line 412: Line 415:
</source>
</source>


= Useful git aliases =
== Useful git aliases ==


This is a snapshot of my ~/.gitconfig
This is a snapshot of my ~/.gitconfig
Line 450: Line 453:
</source>
</source>


= Quick Start Guide =
== Quick Start Guide ==


* [[Git - Quick Start|Using Git for collaborating on text-based data files]]
* [[Git - Quick Start|Using Git for collaborating on text-based data files]]


= Links =
== Links ==


;http://qugstart.com/blog/ruby-and-rails/create-a-new-git-remote-repository-from-some-local-files-or-local-git-repository/
;http://qugstart.com/blog/ruby-and-rails/create-a-new-git-remote-repository-from-some-local-files-or-local-git-repository/
Line 475: Line 478:
'http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging
'http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging


== Clients ==
=== Clients ===


* [https://sapling-scm.com/docs/introduction/getting-started/ Sapling]
* [https://sapling-scm.com/docs/introduction/getting-started/ Sapling]
**[https://engineering.fb.com/2022/11/15/open-source/sapling-source-control-scalable/ Meta engineering blog entry (2022-11)]
**[https://engineering.fb.com/2022/11/15/open-source/sapling-source-control-scalable/ Meta engineering blog entry (2022-11)]