User Tools

Site Tools


version_control:git_basics

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
version_control:git_basics [2020/09/25 22:51] – [Ignoring files] mithatversion_control:git_basics [2024/04/17 21:53] (current) – [Branching and merging] mithat
Line 2: Line 2:
  
 ===== Clarification ===== ===== Clarification =====
-  * [[https://git-scm.com|git]] ≠ [[https://github.com/|GitHub]]+<WRAP center round tip b60%> 
 +**Git** ≠ **GitHub** 
 +</WRAP> 
 + 
 +There are many Git repository hosting services, and [[https://github.com/|GitHub]] wasn't even the first. Some popular alternatives are [[https://gitlab.com/|GitLab]] and [[https://bitbucket.org|Bitbucket]]. But there are many others. Also, Git is not the only VCS in use today. It was originally created independently of any company to support the development of the Linux operating system. It was later adopted by a number of developers of open-source software for their projects before eventually becoming the de-facto standard VCS it is today for both open-source and proprietary projects.
  
 ===== Basic operations ===== ===== Basic operations =====
Line 17: Line 21:
  
 <WRAP center round tip 90%> <WRAP center round tip 90%>
-Use the ''git rm'' command to delete files instead of the Windows Explorer, the Finder in macOS, your Linux file manager, or other shell commands to delete and move/rename files in a repository. Doing so will simplify staging.+Use the ''git rm'' and ''git mv'' commands to delete and move/rename files instead of the standard tools in your operating system. Doing so will simplify staging.
 </WRAP> </WRAP>
  
 ===== Branching and merging ===== ===== Branching and merging =====
-  * A git repository has a default branch called **master**.+  * A git repository has a default branch called **main**. (In older configurations this may be **master**.)
   * To create a new branch: <code bash>git branch branch-name</code>   * To create a new branch: <code bash>git branch branch-name</code>
   * Switch to an existing branch: <code bash>git checkout branch-name</code>   * Switch to an existing branch: <code bash>git checkout branch-name</code>
Line 27: Line 31:
   * Merge changes in another branch into the current branch: <code bash>git merge branch-name</code>   * Merge changes in another branch into the current branch: <code bash>git merge branch-name</code>
   * Delete a branch that you're not currently in: <code bash>git branch -d branch-name</code>   * Delete a branch that you're not currently in: <code bash>git branch -d branch-name</code>
 +
 +<WRAP center round tip 90%>
 +The new ''[[https://git-scm.com/docs/git-switch|git switch]]'' command is an alternative to some ''git branch'' operations. However, as of this writing, it is still experimental.
 +</WRAP>
  
 ===== Ignoring files ===== ===== Ignoring files =====
   * To make git ignore some files in your project, create a ''.gitignore'' file in the project directory.<file text .gitignore>   * To make git ignore some files in your project, create a ''.gitignore'' file in the project directory.<file text .gitignore>
 # Ignore specific files # Ignore specific files
-nastyfile.txt +my-passwords.txt 
-another-nastyfile.docx+banking-info.docx
  
 # Ignore compiled file(s) # Ignore compiled file(s)
Line 43: Line 51:
  
 <WRAP center round tip 80%> <WRAP center round tip 80%>
-The file name must be ''.gitignore'', not ''.gitignore.txt'' or ''gitignore.txt''. To create a ''.gitignore'' file  in Windows, open the Bash shell in the directory where you want the file and enter: +The file name must be ''.gitignore'', not ''.gitignore.txt'' or ''gitignore.txt''. To create a ''.gitignore'' file  in Windows, open the Git Bash shell in the directory where you want the file and enter: 
-<code shell>+<code bash>
 touch .gitignore touch .gitignore
 </code> </code>
version_control/git_basics.1601074305.txt.gz · Last modified: 2020/09/25 22:51 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki